7465: Triangle Collision

内存限制:128 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:4 通过:0

题目描述


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 (−L2,0), (0,3L2)and (L2,0)respectively.
At the beginning, the speed of the ball in the horizontal direction is vxper second, and that in the vertical direction is vyper second, in other words, the original speed of the ball is vx2+vy2, along with the direction vector (vx,vy).
If the ball is now at the position (x,y), then it will move to the position (x+t⋅vx,y+t⋅vy)after tseconds, 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 αis equal to the reflection angle β.
Now given the side length Lof this triangle, the ball's position (x,y)and its speed (vx,vy)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 kcollisions.

But after the first kcollisions, 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.

输入格式

There are several test cases.
The first line contains an integer T(1≤T≤104), 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, vx, vyand k(1≤L≤104,−104≤x,y,vx,vy≤104,1≤k≤106), 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 kcollisions.
It is also guaranteed for all test cases that the speed of the ball is greater than 0.

输出格式

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 aand the jury's answer be b, and then your answer is considered correct if |a−b|max(1,|b|)≤10−4.

输入样例 复制

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

输出样例 复制

1.00002957
1999998.99997035
1233.99999975
1602959.32782988