F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Triangle Collision

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1510    Accepted Submission(s): 485
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}$.
 

Sample Input
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
 

Sample Output
1.00002957 1999998.99997035 1233.99999975 1602959.32782988
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 23:26:53, Gzip enabled