Eumha Railway 998
Time limit2sMemory limit128 MB
Find the point on the train's straight-line path where it comes closest to a given station, guaranteed to have integer coordinates.
Problem
A passenger is riding the Eumha Railway 998 train.
The train will not stop; it keeps moving from its current position with a constant direction and speed. The passenger wants to jump off at the moment when the train is closest to the station.
Given the station position, the current train position, and the train's movement vector, find the train position where the passenger should jump off.
Input
The first line contains the station coordinates xs and ys. The station is at (xs, ys).
The second line contains xe, ye, dx, and dy. The current train position is (xe, ye), and every second the train moves by dx in the x direction and by dy in the y direction.
All given numbers are integers between -100 and 100, inclusive.
Output
Print the x-coordinate and y-coordinate of the position where the passenger should jump off, separated by a space.
Only inputs whose answer coordinates are integers are given.