Triangle Collision

TimeLimit:2000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
Special Judge
未提交 | 登录后收藏
Problem Description


As depicted in the picture above, there is an extremely small ball inside the area enclosed by an equilateral triangular border whose side length is $L$. The radius of the ball is $10^{-1000}$, which is so small that the ball can be treated as a point.

In order to clearly describe the position of the ball, we build a plane coordinate system based on this triangle. The original point is at the midpoint of the triangle's bottom edge, the X-axis is along with the bottom edge (from left to right), and the Y-axis is along with the height on the bottom edge (from bottom to top). For example, the vertices of the triangle are at the positions $\left(-\frac{L}{2}, 0\right)$, $\left(0, \frac{\sqrt{3} L}{2}\right)$ and $\left(\frac{L}{2}, 0\right)$ respectively.

At the beginning, the speed of the ball in the horizontal direction is $v_x$ per second, and that in the vertical direction is $v_y$ per second, in other words, the original speed of the ball is $\sqrt{{v_x}^2 + {v_y}^2}$, along with the direction vector $(v_x, v_y)$.

If the ball is now at the position $(x, y)$, then it will move to the position $(x + t \cdot v_x, y + t \cdot v_y)$ after $t$ seconds, if it does not touch the border during this process.



When the ball hits any edge of the border, a completely elastic collision occurs, which means the moving direction of this ball will change according to the law of reflection, but its speed will not.

The law of reflection follows the rule of "incident angle equals reflection angle". As depicted in the picture above, the incident angle $\alpha$ is equal to the reflection angle $\beta$.

Now given the side length $L$ of this triangle, the ball's position $(x, y)$ and its speed $(v_x, v_y)$ at the beginning, can you calculate the time when the $k$-th collision occurs?

It is guaranteed that the ball does not touch any vertex of the triangle within the first $k$ collisions.



But after the first $k$ collisions, the ball may touch any vertex of the triangle, for example, in the third sample case.

The claim that the ball does not touch any vertex of the triangle means that the distances from the ball to the nearest two sides of the triangle will not equal to the ball's radius at the same time.
Input
There are several test cases.

The first line contains an integer $T$ $(1 \leq T \leq 10^4)$, denoting the number of test cases. Then follow all the test cases.

For each test case, the only line contains six integers $L$, $x$, $y$, $v_x$, $v_y$ and $k$ $(1 \leq L \leq 10^4, -10^4 \leq x, y, v_x, v_y \leq 10^4, 1 \leq k \leq 10^6)$, representing a problem.

It is guaranteed for all test cases that the ball is strictly inside the triangle at the beginning, and as mentioned above, does not touch any vertex of the triangle within the first $k$ collisions.

It is also guaranteed for all test cases that the speed of the ball is greater than $0$.
Output
For each case, output in one line a real number, denoting the time when the $k$-th collision occurs.

For each output value, your answer is considered correct if its absolute or relative error does not exceed $10^{-4}$. Formally, let your answer be $a$ and the jury's answer be $b$, and then your answer is considered correct if $\frac{|a - b|}{\max(1, |b|)} \leq 10^{-4}$.
SampleInput
4
4000 0 1732 1000 0 1
4000 0 1732 1000 0 1000000
4000 0 1234 0 -1 1
4000 -1000 1 0 1000 925469
SampleOutput
1.00002957
1999998.99997035
1233.99999975
1602959.32782988
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: