Martin's father goes for a jog every morning. Martin follows him several minutes later. His father starts at a position that is X1 metres away from their home and runs rectilinearly at a constant speed of V1 meters per step for N steps.
Martin is standing at X2 meters away from his home. He wonders how fast he must run at some constant speed of V2 meters per step so as to maximize F, where F equals the number of his father's footsteps that Martin will land on during his run.It is given that the first step that Martin will land on, from his starting position, will have been landed on by his father.
Note that if more than one prospective velocity results in the same number of maximum common steps, output the highest prospective velocity as V2.
Write an algorithm to help Martin calculate F and V2.
The first line of the input consists of an integer fatherPos, representing the initial position of Martin's father(X1).
The second line consists of an integer martinPos, representing the initial position of Martin (X2).
The third line consits of an integer velFather, representing the velocity of father(V1).
The last line consists of integer steps , representing the no of steps taken by father(N).
Print the two space-separated integers as the maximum number of common footsteps F and respective speed V2.
1 <= fatherPos < 105
0 <= martinPos <= fatherPos
1 <= velFather <= 104
1 <= steps <= 104
Martin can save a maximum of 21 common footsteps with a velocity of 1 m/steps.