C: Discrete Pursuit |
Robocops Inc. is a toy manufacturer company that develops a robot game in which a cop tries to catch a thief in a field that is simulated with a rectangular grid whose coordinates are denoted by pairs of integers. The resulting pursuit occurs in a discrete time scale: time is modeled with non-negative integers
0, 1, 2,...
An object on the grid has a speed that determines how the object moves during the simulation. A speed is modeled with a pair of integers. The first one is the horizontal speed and the second one is the vertical speed. Additionally, horizontal and vertical speeds may vary in one unit (each one) to simulate slowing or accelerating.
More exactly: if at time k
At time 0
Your task is to develop a program to control the cop in order to catch the thief in an efficient way. Your algorithm should determine the minimum time in which the cop may catch the thief.
The problem input consists of several cases, each one defined by a line with three integer values, separated by blanks, that stand for the initial position a
Output texts for each input case preserve the order in the input file.
For an input case, the output should be an integer that is the minimum time at which the cop may catch the thief.
Input
Output
Sample Input
1 1 1
3 1 0
Sample Output
2
3