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
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
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.
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.
6
Returns: 5
In six seconds the dog made five steps: one with each leg, and then again one with the right rear leg.
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.
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).
806000
Returns: 376000
The dog has just finished resting and it is ready to take another step.
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.
1
Returns: 1
4
Returns: 3
1446
Returns: 686
261
Returns: 141
1767
Returns: 842
2272
Returns: 1078
1863
Returns: 886
2342
Returns: 1101
1411
Returns: 658
1059
Returns: 511
2103
Returns: 987
1588
Returns: 752
1612
Returns: 752
2526
Returns: 1181
172
Returns: 94
3261
Returns: 1534
1719
Returns: 804
2702
Returns: 1269
101
Returns: 47
3926
Returns: 1833
424
Returns: 205
7
Returns: 6
1085
Returns: 517
3866
Returns: 1816
3959
Returns: 1857
3250
Returns: 1525
1977
Returns: 940
2969
Returns: 1401
2244
Returns: 1056
42
Returns: 34
3762
Returns: 1766
3346
Returns: 1568
3686
Returns: 1739
1297
Returns: 611
2329
Returns: 1090
1756
Returns: 834
947
Returns: 455
978
Returns: 470
2148
Returns: 1013
2110
Returns: 987
1475
Returns: 705
1816
Returns: 848
3927
Returns: 1833
996
Returns: 470
141
Returns: 79
2302
Returns: 1081
1537
Returns: 726
2940
Returns: 1378
2821
Returns: 1316
1452
Returns: 691
634199
Returns: 295865
362553
Returns: 169150
588916
Returns: 274741
607070
Returns: 283216
802939
Returns: 374590
209534
Returns: 97760
254241
Returns: 118620
830947
Returns: 387656
885489
Returns: 413083
768599
Returns: 358563
963429
Returns: 449460
985009
Returns: 459519
41023
Returns: 19143
135626
Returns: 63275
354179
Returns: 165239
106735
Returns: 49806
384494
Returns: 179378
610477
Returns: 284799
406242
Returns: 189518
537028
Returns: 250534
570396
Returns: 266107
856508
Returns: 399573
269147
Returns: 125572
105846
Returns: 49397
684355
Returns: 319271
918331
Returns: 428405
927943
Returns: 432898
242013
Returns: 112903
976075
Returns: 455343
737204
Returns: 343912
890733
Returns: 415529
355156
Returns: 165685
233201
Returns: 108805
497941
Returns: 232302
784359
Returns: 365911
119527
Returns: 55772
814658
Returns: 380042
440930
Returns: 205710
638057
Returns: 297657
374229
Returns: 174593
711667
Returns: 332008
918757
Returns: 428607
304257
Returns: 141940
925886
Returns: 431930
814513
Returns: 379988
853337
Returns: 398090
254622
Returns: 118790
852447
Returns: 397668
586269
Returns: 273497
970826
Returns: 452892
99999
Returns: 46668
918090
Returns: 428309
1010
Returns: 472
0
Returns: 0
18
Returns: 14
987654
Returns: 460742
80600
Returns: 37600