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 j^\text{th} classroom on the i^\text{th} floor is A \times i + B \times j. What is the minimum cost to build the new school?

Constraints

For all subtasks:

  • 1 \le A,B \le 10^9
Points Awarded N
6 points 1 \le N \le 5\,000
9 points 1 \le N \le 2 \times 10^5

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

5 5 7

Sample Output

94

Comments

There are no comments at the moment.