Problem Statement
You are playing a turn-based role-playing game. At the moment you are preparing a strategy that will defeat an enemy character in the fewest turns possible. At the beginning of the fight the enemy has HP hitpoints. The enemy dies when their hitpoints become zero or negative.
A less experienced player may simply try attacking each turn, but you know the importance of support skills. In each of your turns you may choose one of the following two actions: either Focus or Attack.
- Focus changes the amount of damage dealt by an Attack performed during your next turn.
- Attack deals some damage to the opponent. If you used Focus during your immediately previous turn, the attack decreases the enemy's hitpoints by buffedAttack. Otherwise, the attack decreases the enemy's hitpoints by normalAttack.
You are given the
Definition
- Class:
- BuffingPixie
- Method:
- fastestVictory
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int fastestVictory(int HP, int normalAttack, int buffedAttack)
- (be sure your method is public)
Constraints
- HP will be between 1 and 10^9, inclusive.
- normalAttack will be between 1 and 10^9, inclusive.
- buffedAttack will be between 1 and 10^9, inclusive.
Examples
5
1
3
Returns: 4
One optimal strategy looks as follows: Turn 1: Focus. Turn 2: Attack. Our enemy's hitpoints decrease from 5 to 2. Turn 3: Focus. Turn 4: Attack. Our enemy's hitpoints decrease from 2 to -1.
10
20
50
Returns: 1
You can win by simply attacking on the first turn.
24
2
5
Returns: 10
497
40
45
Returns: 13
8400
1
5
Returns: 3360
10
2
1
Returns: 5
Note that buffedAttack does not have to be greater than normalAttack.
452405440
254158163
67177178
Returns: 2
315089625
119477419
202747595
Returns: 3
694729965
27604604
87800967
Returns: 16
565700293
75115199
64342583
Returns: 8
818382871
278408251
142507970
Returns: 3
850657885
54054412
48820118
Returns: 16
237784464
61796248
31083543
Returns: 4
919703641
125011306
81925545
Returns: 8
706749559
12466847
65591678
Returns: 22
849508966
223502730
75236026
Returns: 4
382496971
27768538
28142689
Returns: 14
139239803
56380425
75198049
Returns: 3
250319182
67363635
38685878
Returns: 4
902237343
36521019
116796342
Returns: 16
506598654
189384775
68004574
Returns: 3
790069939
131293259
128518456
Returns: 7
459664699
161107600
82403081
Returns: 3
635079436
245034579
89499775
Returns: 3
622996886
67495761
4506729
Returns: 10
700003678
12613999
45122057
Returns: 32
1000000000
5
7
Returns: 200000000
1000000000
4
10
Returns: 200000000
1000000000
5
10
Returns: 200000000
1000000000
1
1
Returns: 1000000000
119
1
10
Returns: 24
119
6
10
Returns: 20
1000000000
999999998
999999999
Returns: 2
4
1
3
Returns: 3
1
1000000000
2
Returns: 1
7
1
4
Returns: 4
1000000000
1
3
Returns: 666666667