Statistics

Problem Statement for "SlayingDeer"

Problem Statement

Although TopCoder member Running Wild is a vegetarian, he has recently decided that he would eat venison if he could catch a deer himself. Before committing too much time and effort to this endeavor, Running Wild would like to estimate his chances at success. To do this, he assumes that he will run at a constant speed of A meters per minute without ever getting tired. Similarly, a deer will run at a constant speed of B meters per minute, but after every 30 minutes of running, it must stop and rest for 15 minutes. Finally, Running Wild also assumes that he will begin at a given distance of C meters behind the deer, and that they will always be running in the same fixed direction.

Create a class SlayingDeer that contains a method getTime, which is given an int A, an int B, and an int C, representing the quantities described above. The method should return the number of minutes (rounded up) it will take for Running Wild to catch the deer. If Running Wild will never catch the deer, the method should return -1.

Definition

Class:
SlayingDeer
Method:
getTime
Parameters:
int, int, int
Returns:
int
Method signature:
int getTime(int A, int B, int C)
(be sure your method is public)

Notes

  • If Running Wild and the deer are at precisely the same position, then Running Wild is considered to have caught the deer.

Constraints

  • A and B will be between 1 and 1000 inclusive.
  • C will be between 1 and 100000 inclusive.

Examples

  1. 5

    4

    20

    Returns: 20

    Running Wild gains one meter per minute over the first 20 minutes before catching the deer.

  2. 5

    4

    47

    Returns: 34

    As in the previous example, Running Wild will gain 1 meter per minute for the first 30 minutes. Then, however, the deer stops and rests. Running Wild gains 5 meters per minute while the deer is resting. Note that the answer is rounded up.

  3. 10

    17

    1

    Returns: -1

  4. 133

    198

    7515

    Returns: 7515

  5. 1

    1000

    15819

    Returns: -1

  6. 10

    15

    1

    Returns: -1

    Boundary case - deer and Running Wild are exactly even.

  7. 1

    1

    100000

    Returns: 300010

    Boundary case - Running Wild catches up in about the maximum time.

  8. 976

    534

    91938

    Returns: 154

  9. 786

    72

    50338

    Returns: 69

  10. 262

    388

    15409

    Returns: 4635

  11. 70

    644

    27135

    Returns: -1

  12. 634

    75

    547

    Returns: 1

  13. 41

    60

    98096

    Returns: 98100

  14. 751

    714

    7798

    Returns: 39

  15. 334

    244

    56991

    Returns: 346

  16. 492

    733

    35017

    Returns: 10530

  17. 111

    165

    26298

    Returns: 26325

  18. 381

    571

    73550

    Returns: 220680

  19. 272

    406

    80151

    Returns: 60120

  20. 354

    530

    74926

    Returns: 112410

  21. 440

    744

    3184

    Returns: -1

  22. 399

    594

    9327

    Returns: 3150

  23. 530

    794

    77304

    Returns: 115965

  24. 556

    324

    96689

    Returns: 292

  25. 519

    782

    28941

    Returns: -1

  26. 213

    319

    18864

    Returns: 56610

  27. 777

    979

    42613

    Returns: 358

  28. 162

    239

    68496

    Returns: 25695

  29. 113

    983

    83716

    Returns: -1

  30. 518

    774

    11100

    Returns: 5580

  31. 43

    69

    27473

    Returns: -1

  32. 606

    907

    89127

    Returns: 66870

  33. 342

    508

    69601

    Returns: 20925

  34. 196

    290

    40376

    Returns: 15165

  35. 460

    534

    80762

    Returns: 803

  36. 16

    22

    88458

    Returns: 66373

  37. 384

    572

    88242

    Returns: 33120

  38. 423

    634

    44930

    Returns: 134820

  39. 599

    219

    23839

    Returns: 55

  40. 184

    273

    20420

    Returns: 10215

  41. 577

    865

    52801

    Returns: 158445

  42. 39

    55

    82504

    Returns: 35370

  43. 288

    430

    90622

    Returns: 67995

  44. 560

    443

    58028

    Returns: 223

  45. 528

    634

    52834

    Returns: 533

  46. 991

    473

    25755

    Returns: 41

  47. 193

    286

    91635

    Returns: 39285

  48. 689

    604

    55340

    Returns: 212

  49. 14

    971

    55944

    Returns: -1

  50. 652

    975

    53200

    Returns: 26640

  51. 667

    1000

    100000

    Returns: 300015

  52. 2

    3

    1

    Returns: -1

  53. 1

    1

    15

    Returns: 45

  54. 133

    198

    7515

    Returns: 7515

  55. 30

    45

    10000

    Returns: -1

  56. 2

    3

    100000

    Returns: -1

  57. 667

    1000

    100000

    Returns: 300015

  58. 1

    1

    1

    Returns: 31

  59. 2

    3

    10

    Returns: -1

  60. 30

    45

    100000

    Returns: -1

  61. 30

    45

    1000

    Returns: -1

  62. 1

    1

    100000

    Returns: 300010

  63. 30

    45

    50

    Returns: -1

  64. 11

    12

    2

    Returns: 33

  65. 1

    1

    2

    Returns: 32

  66. 6

    6

    1

    Returns: 31

  67. 1

    1

    10

    Returns: 40

  68. 3

    4

    1

    Returns: 41

  69. 30

    45

    100

    Returns: -1

  70. 10

    15

    1000

    Returns: -1

  71. 30

    45

    9000

    Returns: -1

  72. 2

    3

    100

    Returns: -1

  73. 30

    45

    30

    Returns: -1

  74. 5

    4

    32

    Returns: 31

  75. 16

    24

    10000

    Returns: -1

  76. 1000

    1

    1

    Returns: 1

  77. 1

    1000

    15819

    Returns: -1

  78. 2

    3

    200

    Returns: -1

  79. 10

    1

    100

    Returns: 12

  80. 2

    3

    300

    Returns: -1

  81. 4

    2

    7

    Returns: 4

  82. 5

    4

    47

    Returns: 34

  83. 2

    3

    10000

    Returns: -1

  84. 4

    4

    10

    Returns: 33

  85. 3

    4

    6

    Returns: 42

  86. 30

    45

    1

    Returns: -1

  87. 3

    4

    16

    Returns: 86


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: