Hotel Hosting Costs

Hotel Hosting Costs

The hotel has a promotion for the July vacations. The promotion is valid for those who arrive from July 1st and leave on August 1st. The price of the hotel rate is lower for those who arrive earlier, and increases every day. More precisely, the promotion works like this:

example

  • The daily rate of the hotel for each who arrives on day 1 is rate. Thus, those who arrive on day 1 will pay a total of 31 * rate.
  • The hotel rate increases to the incr per day. That is, the daily rate is rate + incr for those who arrive on day 2; rate + 2 * incr on the 3rd day and so on.
  • From the 16th day onwards, the daily rate no longer increases.

Note that those who arrive on day 2 will pay a total of 30 × (rate + incr); those who arrive on day 3 will pay a total of 29 × (rate + 2 × incr) and so on.

Given the day of arrival (1 ≤ day ≤ 31), the initial rate and the daily increase incr, calculate the total amount to be paid by a customer who arrives on that day.

Input: Three integers (int).

Output: Integer.

Examples:

assert hotel_cost(100, 10, 1) == 3100
assert hotel_cost(100, 20, 15) == 6460
assert hotel_cost(100, 5, 16) == 2720
assert hotel_cost(150, 10, 15) == 4930