Cheerio Contest 1 S2 - School Expansion

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 512M

Authors:
Problem type

RHHS is a very popular school and has a very large number of students. However, this year there are too many students and not enough rooms for all of them. You have been tasked with building a new school building to accommodate N classrooms.

The new school can have an unlimited number of floors, provided that there are no gaps in the building. Each floor can have an unlimited number of rooms. The cost of building the jth classroom on the ith floor is A×i+B×j. What is the minimum cost to build the new school?

Constraints

For all subtasks:

  • 1A,B109
Points Awarded N
6 points 1N5000
9 points 1N2×105

Input Specification

The first and only line contains three integers N, A, and B.

Output Specification

Output the minimum cost required to build the new school. Please note that this number may not fit inside a 32-bit integer.

Sample Input

Copy
5 5 7

Sample Output

Copy
94

Comments

There are no comments at the moment.