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
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
5
4
20
Returns: 20
Running Wild gains one meter per minute over the first 20 minutes before catching the deer.
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.
10
17
1
Returns: -1
133
198
7515
Returns: 7515
1
1000
15819
Returns: -1
10
15
1
Returns: -1
Boundary case - deer and Running Wild are exactly even.
1
1
100000
Returns: 300010
Boundary case - Running Wild catches up in about the maximum time.
976
534
91938
Returns: 154
786
72
50338
Returns: 69
262
388
15409
Returns: 4635
70
644
27135
Returns: -1
634
75
547
Returns: 1
41
60
98096
Returns: 98100
751
714
7798
Returns: 39
334
244
56991
Returns: 346
492
733
35017
Returns: 10530
111
165
26298
Returns: 26325
381
571
73550
Returns: 220680
272
406
80151
Returns: 60120
354
530
74926
Returns: 112410
440
744
3184
Returns: -1
399
594
9327
Returns: 3150
530
794
77304
Returns: 115965
556
324
96689
Returns: 292
519
782
28941
Returns: -1
213
319
18864
Returns: 56610
777
979
42613
Returns: 358
162
239
68496
Returns: 25695
113
983
83716
Returns: -1
518
774
11100
Returns: 5580
43
69
27473
Returns: -1
606
907
89127
Returns: 66870
342
508
69601
Returns: 20925
196
290
40376
Returns: 15165
460
534
80762
Returns: 803
16
22
88458
Returns: 66373
384
572
88242
Returns: 33120
423
634
44930
Returns: 134820
599
219
23839
Returns: 55
184
273
20420
Returns: 10215
577
865
52801
Returns: 158445
39
55
82504
Returns: 35370
288
430
90622
Returns: 67995
560
443
58028
Returns: 223
528
634
52834
Returns: 533
991
473
25755
Returns: 41
193
286
91635
Returns: 39285
689
604
55340
Returns: 212
14
971
55944
Returns: -1
652
975
53200
Returns: 26640
667
1000
100000
Returns: 300015
2
3
1
Returns: -1
1
1
15
Returns: 45
133
198
7515
Returns: 7515
30
45
10000
Returns: -1
2
3
100000
Returns: -1
667
1000
100000
Returns: 300015
1
1
1
Returns: 31
2
3
10
Returns: -1
30
45
100000
Returns: -1
30
45
1000
Returns: -1
1
1
100000
Returns: 300010
30
45
50
Returns: -1
11
12
2
Returns: 33
1
1
2
Returns: 32
6
6
1
Returns: 31
1
1
10
Returns: 40
3
4
1
Returns: 41
30
45
100
Returns: -1
10
15
1000
Returns: -1
30
45
9000
Returns: -1
2
3
100
Returns: -1
30
45
30
Returns: -1
5
4
32
Returns: 31
16
24
10000
Returns: -1
1000
1
1
Returns: 1
1
1000
15819
Returns: -1
2
3
200
Returns: -1
10
1
100
Returns: 12
2
3
300
Returns: -1
4
2
7
Returns: 4
5
4
47
Returns: 34
2
3
10000
Returns: -1
4
4
10
Returns: 33
3
4
6
Returns: 42
30
45
1
Returns: -1
3
4
16
Returns: 86