No.410 Meeting
タグ : / 解いたユーザー数 642
作問者 :
nmnmnmnmnmnmnm
Problem Statement
Initially, A is at an integer coordinate point P on the XY plane, and B is at an integer coordinate point Q.
Both A and B can move, per second, by -1 or +1 in the X-axis direction, or by -1 or +1 in the Y-axis direction.
(Movement is possible only in directions parallel to the X-axis or the Y-axis.)
A and B have decided on a meeting place so that they can meet in the shortest time.
Find the shortest time in which A and B can meet when they start moving at the same time.
Input
$P_X$ $P_Y$ $Q_X$ $Q_Y$
$P_X$ $P_Y$ are the initial coordinates ($P_X$,$P_Y$) of A. Point P has integer coordinates.
$Q_X$ $Q_Y$ are the initial coordinates ($Q_X$,$Q_Y$) of B. Point Q has integer coordinates.
$-100000 \le P_X,P_Y,Q_X,Q_Y \le 100000$
The coordinates of point P and point Q are different.
Output
Output the shortest time (in seconds) in which A and B meet, on one line.
As long as the value itself is correct (about 20 digits as a guideline), you may output redundant digits after the decimal point.
Do not forget the newline at the end.
Sample
Sample 1
Input
0 0 2 0
Output
1
A is initially at point P(0,0). B is initially at point Q(2,0).
If they choose point (1,0) as the meeting place, they can meet after 1 second.
Sample 2
Input
0 0 3 0
Output
1.5
A is initially at point P(0,0). B is initially at point Q(3,0).
If they choose (1.5,0) as the meeting place, they can meet after 1.5 seconds.
The meeting place does not necessarily have to be at integer coordinates.
Sample 3
Input
0 0 5 1
Output
3
A is initially at point P(0,0). B is initially at point Q(5,1).
For example, if they choose (3,0) as the meeting place, they can meet in the shortest time, after 3 seconds.
There are also candidates for the meeting place other than (3,0).
Sample 4
Input
-12345 6789 1234 -56789
Output
38578.5
Note that the input coordinates may include negative values.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。