/
Time Limit: 2 sec / Memory Limit: 1024 MiB
問題文
T 君と A 君が 2 次元平面上で徒競走をしています。 T 君は (T_x,T_y) がスタート地点であり、1 秒あたり V_T の速さで走ります。 A 君は (A_x,A_y) がスタート地点であり、1 秒あたり V_A の速さで走ります。
笛がなると、2 人はそれぞれのスタート地点から一斉にゴール地点に向かって走り出します。 ゴール地点は 2 人に共通で、その x 座標は 0 と決まっていますが、y 座標はまだ決まっていません(ここで、T_x \neq 0 かつ A_x \neq 0 が保証されます)。
あなたは、T 君がこの徒競走に負けないように(すなわち、T 君が先にゴール地点に到着するか、2 人が同時にゴール地点に到着するように)ゴール地点の y 座標を決めたいです。 この目的を達成できる y 座標の値の集合を S としたとき、
- S が空ならば、0
- S が空でなく、かつ S の最小値と最大値が共に存在するならば、最大値と最小値の差
- S が空でないが、S の最小値と最大値のうち少なくとも一方が存在しないならば、
inf
をそれぞれ出力してください。
制約
- -10^4 \leq T_x,T_y,A_x,A_y \leq 10^4
- T_x \neq 0
- A_x \neq 0
- 1 \leq V_T,V_A \leq 10^2
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
T_x T_y V_T A_x A_y V_A
出力
答えを実数または文字列 inf として出力せよ。
答えが実数の場合、出力は真の値との絶対誤差または相対誤差が 10^{−9} 以下のとき正解と判定される。
入力例 1
1 0 1 1 3 2
出力例 1
3.464101615137754
ゴール地点の y 座標について、2 つの具体例を挙げます。
- y=0 のとき:ゴール地点に到達するまでに、T 君は \frac{1}{1}=1 秒、A 君は \frac{\sqrt{10}}{2}=1.58\dots 秒かかります。
- y=2 のとき:ゴール地点に到達するまでに、T 君は \frac{\sqrt{5}}{1}=2.23\dots 秒、A 君は \frac{\sqrt{2}}{2}=0.70\dots 秒かかります。
T 君が先にゴール地点に到着するか、2 人が同時にゴール地点に到着する条件は -1-\sqrt{3} \leq y \leq -1+\sqrt{3} であることが証明できます。
よって、S の最大値は -1+\sqrt{3}、最小値は -1-\sqrt{3} であり、答えは (-1+\sqrt{3})-(-1-\sqrt{3})=2\sqrt{3}=3.46\dots です。
入力例 2
3 0 1 3 3 2
出力例 2
0
ゴール地点の y 座標によらず A 君は T 君より先にゴール地点に到達するため、S は空です。
入力例 3
4 -10 10 -1 3 5
出力例 3
inf
S には最大値も最小値も存在しません。
Problem Statement
Two runners, T and A, are competing in a footrace on a two-dimensional plane. T starts at (T_x,T_y) and runs at a speed of V_T per second. A starts at (A_x,A_y) and runs at a speed of V_A per second.
Once the whistle is blown, they start running simultaneously from their individual starting points toward a common goal. The goal has a fixed x coordinate of 0, but its y coordinate is not determined yet. (Here, it is guaranteed that T_x \neq 0 and A_x \neq 0.)
You want to determine the y coordinate of the goal so that T never loses the race (that is, T reaches the goal first, or the two runners reach the goal at the same time). Let S be the set of y coordinates that achieve the objective.
- If S is empty, print 0;
- if S is non-empty, and S has both the maximum and minimum values, then print the difference between them;
- if S is non-empty, but S does not have both the maximum and minimum values, then print
inf.
Constraints
- -10^4 \leq T_x,T_y,A_x,A_y \leq 10^4
- T_x \neq 0
- A_x \neq 0
- 1 \leq V_T,V_A \leq 10^2
- All input values are integers.
Input
The input is given from Standard Input in the following format:
T_x T_y V_T A_x A_y V_A
Output
Print the result as a real value, or inf.
If the answer is a real value, your output is considered correct if its absolute or relative error from the true value is at most 10^{−9}.
Sample Input 1
1 0 1 1 3 2
Sample Output 1
3.464101615137754
We consider two y coordinates of the goal as examples.
- If y=0: it takes \frac{1}{1}=1 seconds for T, and \frac{\sqrt{10}}{2}=1.58\dots seconds for A, to reach the goal.
- If y=2: it takes \frac{\sqrt{5}}{1}=2.23\dots seconds for T, and \frac{\sqrt{2}}{2}=0.70\dots seconds for A, to reach the goal.
One can prove that T reaches the goal first, or the two runners reach the goal at the same time if and only if -1-\sqrt{3} \leq y \leq -1+\sqrt{3}.
Thus, the maximum value of S is -1+\sqrt{3}, and its minimum value is -1-\sqrt{3}, so the answer is (-1+\sqrt{3})-(-1-\sqrt{3})=2\sqrt{3}=3.46\dots.
Sample Input 2
3 0 1 3 3 2
Sample Output 2
0
Regardless of the y coordinate of the goal, A always reaches the goal earlier than T, so S is empty.
Sample Input 3
4 -10 10 -1 3 5
Sample Output 3
inf
S has neither the maximum nor minimum value.