#t486. 雇佣兵
雇佣兵
Mercenary
Problem Description
A mercenary has a maximum stamina of , starting stamina , combat power , and energy elements.
The mercenary may join a battle period of days only when his stamina is exactly ; at the end of a battle period his stamina returns to . Within one battle period, every consecutive days of fighting raises his combat power by point, where is the combat power at the start of that battle period. Also, each time a battle period begins, one energy element's worth of stamina is consumed.
After a battle period ends, the mercenary must use several energy elements to restore his stamina to the maximum so he can join the next battle period. Each energy element restores at most the current combat power worth of stamina, and each energy element can be used only once.
What is the maximum combat power the mercenary can reach?
Input Format
One line with three integers , separated by single spaces. are all positive integers not exceeding .
Output Format
One integer: the mercenary's maximum combat power.
Sample Input
5 2 10
Sample Output
6
Constraints
.
Hint
- In the first round, energy elements are needed and combat power can rise to ; elements remain.
- In the second round, elements are needed and combat power can rise to ; remain.
- In the third round, element is needed and combat power can rise to ; remain.
- Once a round would need more energy elements than you have left, you stop.
- The combat power stops growing when would consume an element but the rounding no longer increases power (here from round 4 on, power stays ); keep spending one element per round until you run out.