AtCoder Beginner Contest 183
B
Billiards
AtCoder
⌀ 0
原题
← AC →
翻译中…

Problem Statement

翻译中…

Takahashi is playing billiards on a two-dimensional plane. The $x$-axis functions as a wall; when a ball hits the axis, it will bounce off the axis so that the angle of incidence equals the angle of reflection.

翻译中…

Takahashi's ball is now at $(S_x,S_y)$. When he strikes the ball aiming for some point, it will roll in a straight line towards that point.

翻译中…

To make the ball hit the $x$-axis exactly once and then pass $(G_x, G_y)$, where along the $x$-axis should he aim for?

翻译中…

Constraints

翻译中…
  • $-10^6 \leq S_x, G_x \leq 10^6$
  • $0 < S_y, G_y \leq 10^6$
  • $S_x \neq G_x$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

S_x S_y G_x G_y

翻译中…

Output

翻译中…

Let $(x, 0)$ be the point Takahashi should aim for. Print $x$.

翻译中…

Your output will be considered correct when its absolute or relative error from our answer is at most $10^{-6}$.

翻译中…

样例

Input #1
1 1 7 2
Output #1
3.0000000000
As shown below, we can make the ball pass $(7, 2)$ by striking it aiming for $(3, 0)$. ![Figure](https://img.atcoder.jp/ghi/c9595d59f1139b808d4cf3d31d6b48ee.png)
Input #2
1 1 3 2
Output #2
1.6666666667
![Figure](https://img.atcoder.jp/ghi/4f2c808fddc9bb349999f8969996ebb9.png)
Input #3
-9 99 -999 9999
Output #3
-18.7058823529
The output will be considered correct when its absolute or relative error from our answer is at most $10^{-6}$.
题目信息
题号
abc183_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。