Statistics

Problem Statement for "BuffingPixie"

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 ints HP, normalAttack and buffedAttack. Return the smallest number of turns in which you can kill the enemy.

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

  1. 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.

  2. 10

    20

    50

    Returns: 1

    You can win by simply attacking on the first turn.

  3. 24

    2

    5

    Returns: 10

  4. 497

    40

    45

    Returns: 13

  5. 8400

    1

    5

    Returns: 3360

  6. 10

    2

    1

    Returns: 5

    Note that buffedAttack does not have to be greater than normalAttack.

  7. 452405440

    254158163

    67177178

    Returns: 2

  8. 315089625

    119477419

    202747595

    Returns: 3

  9. 694729965

    27604604

    87800967

    Returns: 16

  10. 565700293

    75115199

    64342583

    Returns: 8

  11. 818382871

    278408251

    142507970

    Returns: 3

  12. 850657885

    54054412

    48820118

    Returns: 16

  13. 237784464

    61796248

    31083543

    Returns: 4

  14. 919703641

    125011306

    81925545

    Returns: 8

  15. 706749559

    12466847

    65591678

    Returns: 22

  16. 849508966

    223502730

    75236026

    Returns: 4

  17. 382496971

    27768538

    28142689

    Returns: 14

  18. 139239803

    56380425

    75198049

    Returns: 3

  19. 250319182

    67363635

    38685878

    Returns: 4

  20. 902237343

    36521019

    116796342

    Returns: 16

  21. 506598654

    189384775

    68004574

    Returns: 3

  22. 790069939

    131293259

    128518456

    Returns: 7

  23. 459664699

    161107600

    82403081

    Returns: 3

  24. 635079436

    245034579

    89499775

    Returns: 3

  25. 622996886

    67495761

    4506729

    Returns: 10

  26. 700003678

    12613999

    45122057

    Returns: 32

  27. 1000000000

    5

    7

    Returns: 200000000

  28. 1000000000

    4

    10

    Returns: 200000000

  29. 1000000000

    5

    10

    Returns: 200000000

  30. 1000000000

    1

    1

    Returns: 1000000000

  31. 119

    1

    10

    Returns: 24

  32. 119

    6

    10

    Returns: 20

  33. 1000000000

    999999998

    999999999

    Returns: 2

  34. 4

    1

    3

    Returns: 3

  35. 1

    1000000000

    2

    Returns: 1

  36. 7

    1

    4

    Returns: 4

  37. 1000000000

    1

    3

    Returns: 666666667


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: