After a few years from primary school, CL remembered about a cartoon he used to love a lot and always discussed with his friends, Shinkansen Henkei RoboShinkalion In the cartoon, lots of evil robots are scattered around the city, no one knew what to do. One day, Hayato Hayasugi, a young grade schooler who is a big rail-fan due to his father being a member of staff at the Railway Museum, accidentally got involved in the recent attack by the monsters and discovered his father's secret working with the Shinkansen Ultra Evolution Institute. After a test, Hayato had a 96% match rate with the Shinkansen robot ! However despite initial concerns from the adult members of the organization about having children as drivers, Hayato joins several other kids in using Shinkalions to willingly fight against the threat of the Kitoralsus. As more and more Shinkalions get into battle, CL loved the Shinkalion, Dr Yellow’s railgun a lot. Being a rail-fan (Not 鐵路迷, but Rail Gun fan), CL decided to replicate Dr Yellow’s railgun and conduct an experiment.
(Fig.1 Dr Yellow)
(Fig.2 Hayato Hayasugi)
Later that day, CL found out that Peppa and her $N-1$ friends are in the park playing together, what a coincidence! CL immediately gave each person (animal) 1 rail gun. He then numbered Peppa and her friends $1, 2, ..., N$ and scattered them in the park. The park can be treated as an infinite-sized Cartesian plane. In the experiment, everyone initially faces $0$ degrees, or the positive y-axis direction. At the beginning, the $1$-st person will start rotating at a given speed, when the direction of the $1$-st person is facing the $2$-nd person, he fires the rail gun. (As rail guns are high technology weapons, you may assume that they hit the other target instantly). After hitting the $2$-nd person, he/she will repeat the same action as the $1$-st by rotating at his own speed and fires the rail gun towards the $3$-rd person, until the $N$-th person was shot by a rail gun. CL wants to know how long does it take for the $N$-th person get shot by the rail gun after the $1$-st person starts rotating.
You are given the number of people, $N$, and each of their responding coordinates, $(X_i, Y_i)$ and the rotation speed of every person. More precisely, the time needed for the $i$-th person to rotate $D_i$ degrees is $T_i$ seconds.
Input
The first line contains 1 integer, $N$.
The following $N$ lines each contain 4 integers describing the $i$-th person, which are $X_i, Y_i, D_i, T_i$ separated by a single space.
Output
Output the time when the $N$-th person is shot by the rail gun. Your answer will be considered correct if its absolute or relative error doesn't exceed $10^{-6}$. Formally, if your answer is $a$, and the expected answer is $b$, your answer will be accepted if $\frac{|a-b|}{max(1,b)} \le 10^{-6}$ .
Constraints
For all cases, $2 \le N \le 1000$, $0 \le Y_i \le 10^6$, $1 \le D_i, T_i \le 10^6$, $0 \le X_1 \le X_2 \le ...\le X_N \le 10^6$
Subtask 1 (10%): $X_1 = X_2 = ... = X_N$, $Y_1 < Y_2 < ... < Y_N$
Subtask 2 (40%): $Y_1 = Y_2 = ... = Y_N$
Subtask 3 (50%): No additional constraints
Hints
For two person $A(x, y)$ and $B(xx, yy)$ with $ x < xx$, the rotation required for $A$ to rotate to $B$ in degree is deg
:
const double PI = acos(-1); double slope = (yy - y) / (xx - x); double deg = 90. - atan(slope) * 180. / PI;
Sample Test Cases
Input | Output | |
---|---|---|
3 0 0 100 1 3 4 120 4 10 1 400 2 |
4.141985 | |
Illustration for sample 1: |
||
3 0 1 100 1 1 1 100 1 2 1 100 1 |
1.800000 |
Scoring: Per Subtask
Authored by wy23493
Appeared in WYHK 2025 Mini Contest 0 [Session 2] and WYHK 2025 Mini Contest 0