Statistics

Problem Statement for "LimpingDog"

Problem Statement

A limping dog is walking forward. The dog moves one leg at a time, in the following cyclic order: right rear, right front, left rear, left front.

The dog's left rear leg is injured and moving it takes two seconds. A step with any other leg takes only one second.

After every 47 completed steps the dog takes a 42-second break.

You are given the int time. Return the number of steps the dog has completed in the given time.

Definition

Class:
LimpingDog
Method:
countSteps
Parameters:
int
Returns:
int
Method signature:
int countSteps(int time)
(be sure your method is public)

Constraints

  • time will be between 0 and 10^6, inclusive.

Examples

  1. 2

    Returns: 2

    In the first two seconds the dog made one step with his right rear leg and one step with his right front leg.

  2. 3

    Returns: 2

    After three seconds the dog is in the middle of stepping with his injured left rear leg. Thus, the number of completed steps is still only 2.

  3. 6

    Returns: 5

    In six seconds the dog made five steps: one with each leg, and then again one with the right rear leg.

  4. 80

    Returns: 47

    The dog has made the first 47 steps and it is now right in the middle of its first 42-second rest.

  5. 104

    Returns: 50

    The dog finished its first rest and then it made three more steps. Note that the rest does not reset the order in which the dog moves its legs. The last leg moved before the rest was the injured left rear leg, so the first three steps after the rest are the left front, right rear, and right front leg (taking one second each).

  6. 806000

    Returns: 376000

    The dog has just finished resting and it is ready to take another step.

  7. 54321

    Returns: 25346

    During the first 54321 seconds the dog has rested 539 times, it completed 25346 steps, and it is now in the middle of moving the injured leg again.

  8. 1

    Returns: 1

  9. 4

    Returns: 3

  10. 1446

    Returns: 686

  11. 261

    Returns: 141

  12. 1767

    Returns: 842

  13. 2272

    Returns: 1078

  14. 1863

    Returns: 886

  15. 2342

    Returns: 1101

  16. 1411

    Returns: 658

  17. 1059

    Returns: 511

  18. 2103

    Returns: 987

  19. 1588

    Returns: 752

  20. 1612

    Returns: 752

  21. 2526

    Returns: 1181

  22. 172

    Returns: 94

  23. 3261

    Returns: 1534

  24. 1719

    Returns: 804

  25. 2702

    Returns: 1269

  26. 101

    Returns: 47

  27. 3926

    Returns: 1833

  28. 424

    Returns: 205

  29. 7

    Returns: 6

  30. 1085

    Returns: 517

  31. 3866

    Returns: 1816

  32. 3959

    Returns: 1857

  33. 3250

    Returns: 1525

  34. 1977

    Returns: 940

  35. 2969

    Returns: 1401

  36. 2244

    Returns: 1056

  37. 42

    Returns: 34

  38. 3762

    Returns: 1766

  39. 3346

    Returns: 1568

  40. 3686

    Returns: 1739

  41. 1297

    Returns: 611

  42. 2329

    Returns: 1090

  43. 1756

    Returns: 834

  44. 947

    Returns: 455

  45. 978

    Returns: 470

  46. 2148

    Returns: 1013

  47. 2110

    Returns: 987

  48. 1475

    Returns: 705

  49. 1816

    Returns: 848

  50. 3927

    Returns: 1833

  51. 996

    Returns: 470

  52. 141

    Returns: 79

  53. 2302

    Returns: 1081

  54. 1537

    Returns: 726

  55. 2940

    Returns: 1378

  56. 2821

    Returns: 1316

  57. 1452

    Returns: 691

  58. 634199

    Returns: 295865

  59. 362553

    Returns: 169150

  60. 588916

    Returns: 274741

  61. 607070

    Returns: 283216

  62. 802939

    Returns: 374590

  63. 209534

    Returns: 97760

  64. 254241

    Returns: 118620

  65. 830947

    Returns: 387656

  66. 885489

    Returns: 413083

  67. 768599

    Returns: 358563

  68. 963429

    Returns: 449460

  69. 985009

    Returns: 459519

  70. 41023

    Returns: 19143

  71. 135626

    Returns: 63275

  72. 354179

    Returns: 165239

  73. 106735

    Returns: 49806

  74. 384494

    Returns: 179378

  75. 610477

    Returns: 284799

  76. 406242

    Returns: 189518

  77. 537028

    Returns: 250534

  78. 570396

    Returns: 266107

  79. 856508

    Returns: 399573

  80. 269147

    Returns: 125572

  81. 105846

    Returns: 49397

  82. 684355

    Returns: 319271

  83. 918331

    Returns: 428405

  84. 927943

    Returns: 432898

  85. 242013

    Returns: 112903

  86. 976075

    Returns: 455343

  87. 737204

    Returns: 343912

  88. 890733

    Returns: 415529

  89. 355156

    Returns: 165685

  90. 233201

    Returns: 108805

  91. 497941

    Returns: 232302

  92. 784359

    Returns: 365911

  93. 119527

    Returns: 55772

  94. 814658

    Returns: 380042

  95. 440930

    Returns: 205710

  96. 638057

    Returns: 297657

  97. 374229

    Returns: 174593

  98. 711667

    Returns: 332008

  99. 918757

    Returns: 428607

  100. 304257

    Returns: 141940

  101. 925886

    Returns: 431930

  102. 814513

    Returns: 379988

  103. 853337

    Returns: 398090

  104. 254622

    Returns: 118790

  105. 852447

    Returns: 397668

  106. 586269

    Returns: 273497

  107. 970826

    Returns: 452892

  108. 99999

    Returns: 46668

  109. 918090

    Returns: 428309

  110. 1010

    Returns: 472

  111. 0

    Returns: 0

  112. 18

    Returns: 14

  113. 987654

    Returns: 460742

  114. 80600

    Returns: 37600


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: