## TLE '16 Contest 6 (Mock CCC) J3 - Two Kangaroos

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Papa Kangaroo needs to catch his son, Little Kangaroo, but Little Kangaroo keeps playing around!

Papa Kangaroo starts at point and can hop an integer distance from to units, inclusive.

Little Kangaroo starts at point and can hop only a constant distance of exactly units.

Little Kangaroo, always watching Papa Kangaroo, loves to play. Whenever Papa Kangaroo hops any positive distance, Little Kangaroo simultaneously hops units in the exact same direction as Papa Kangaroo. No Kangaroo can hop diagonally.

What is the minimum number of hops Papa Kangaroo will need to catch his son?

#### Input Specification

The first line will contain the space separated integers , , and in that order.

The second line will contain space separated integers , , and in that order.

• For the first 3 out of the 15 points, .
• For the second 3 out of the 15 points, .
• For the third 3 out of the 15 points, .
• For the fourth 3 out of the 15 points, .

#### Output Specification

Output a single integer representing the minimum number of hops Papa Kangaroo will need for him to end at the same spot as Little Kangaroo.

#### Sample Input

10 10 3
5 5 2

#### Sample Output

10

• commented on June 29, 2017, 5:53 a.m. edited

Clarification

EDIT: I just read it completely wrong, nvm.

• commented on June 23, 2017, 11:09 a.m. edit 5

What does it mean by "positive distance"? Isn't distance by definition always positive?

• commented on June 29, 2017, 5:56 a.m. edited

Alexiev*, Java has to init a virtual machine. It's what gives Java better portability over other languages. (this means it'll be slow for shorter questions like "Hello, world" but faster in other longer ones AFAIK. (Of course I could be completely wrong, I'm open for corrections)

• commented on June 29, 2017, 6:40 p.m.

Java is generally much slower, use C or C++ for fast times. Keep in mind that if you TLE , it's most likely not because of the language, but rather the algorithm.

• commented on Feb. 20, 2017, 12:07 p.m.

do the two kangaroos jump simultaneously?

• commented on Feb. 20, 2017, 12:16 p.m.

Yes.

• commented on Feb. 20, 2017, 11:08 a.m.

Can papa kangaroo hop a distance of 0 units?

• commented on Feb. 20, 2017, 11:10 a.m. edited

If Papa Kangaroo hops 0 distance, Little Kangaroo won't move.

Updated statement to clarify.