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:
- The daily rate of the hotel for each who arrives on
day1 israte. Thus, those who arrive onday1 will pay a total of31 * rate. - The hotel rate increases to the
incrper day. That is, the daily rate israte + incrfor those who arrive onday2;rate + 2 * incron the 3rddayand so on. - From the 16th
dayonwards, 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