#t486. 雇佣兵

雇佣兵

Mercenary

Problem Description

A mercenary has a maximum stamina of MM, starting stamina 00, combat power NN, and XX energy elements.

The mercenary may join a battle period of MM days only when his stamina is exactly MM; at the end of a battle period his stamina returns to 00. Within one battle period, every nn consecutive days of fighting raises his combat power by 11 point, where nn 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 MM 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 M,N,XM, N, X, separated by single spaces. M,N,XM, N, X are all positive integers not exceeding 1000010000.

Output Format

One integer: the mercenary's maximum combat power.

Sample Input

5 2 10

Sample Output

6

Constraints

1≤M,N,X≤100001 \le M, N, X \le 10000.

Hint

  • In the first round, ⌈52⌉\lceil {5\over 2}\rceil energy elements are needed and combat power can rise to 44; 10−3=710 - 3 = 7 elements remain.
  • In the second round, ⌈54⌉\lceil {5\over 4}\rceil elements are needed and combat power can rise to 55; 7−2=57 - 2 = 5 remain.
  • In the third round, ⌈55⌉\lceil {5\over 5}\rceil element is needed and combat power can rise to 66; 5−1=45 - 1 = 4 remain.
  • Once a round would need more energy elements than you have left, you stop.
  • The combat power stops growing when ⌈M/(current power)⌉\lceil M / (\text{current power}) \rceil would consume an element but the rounding no longer increases power (here from round 4 on, power stays 66); keep spending one element per round until you run out.