問題一覧 > 通常問題

No.410 Meeting

レベル : / AI推定難易度 : 111 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $0$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 642
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 974 / 自分の提出
問題文最終更新日: 2026-06-25 09:34:25
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 146 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。