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

View as PDF

Submit solution


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 (x_1, y_1) and can hop an integer distance from 1 to K units, inclusive.

Little Kangaroo starts at point (x_2, y_2) and can hop only a constant distance of exactly L units.

Little Kangaroo, always watching Papa Kangaroo, loves to play. Whenever Papa Kangaroo hops any positive distance, Little Kangaroo simultaneously hops L 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 x_1, y_1 (-5 \times 10^8 \le x_1, y_1 \le 5 \times 10^8), and K (2 \le K \le 1000) in that order.

The second line will contain space separated integers x_2, y_2 (-5 \times 10^8 \le x_2, y_2 \le 5 \times 10^8), and L (1 \le L < K) in that order.

  • For the first 3 out of the 15 points, -25 \le x_1, y_1, x_2, y_2 \le 25.
  • For the second 3 out of the 15 points, -2000 \le x_1, y_1, x_2, y_2 \le 2000.
  • For the third 3 out of the 15 points, -200\,000 \le x_1, y_1, x_2, y_2 \le 200\,000.
  • For the fourth 3 out of the 15 points, -1\,000\,000 \le x_1, y_1, x_2, y_2 \le 1\,000\,000.

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

Comments


  • 0
    serawang  commented on Feb. 20, 2017, 5:07 p.m.

    do the two kangaroos jump simultaneously?


    • 0
      ZQFMGB12  commented on Feb. 20, 2017, 5:16 p.m.

      Yes.