Louis is good at jumping. He could jump especially good with double-jump!! He likes to practice jumping at a playground. Two vertical walls are placed on the playground, each of which has a hole.
The lower sides of the holes in the walls are on heights b1 and b2 respectively, and upper sides on heights t1 and t2. Walls are parallel and placed on distance l from each other.
Louis starts at the distance ds from the first wall. It jumps through the first hole and lands between the walls. After that from that point he jumps through the second hole. The goal is to land exactly at the distance df from the second wall.
Let us describe the jump. Louis starts from the specified point and starts moving in some chosen direction with the speed not exceeding some maximal speed v, determined by the strength of the jumper. The gravity of g forces him down, thus he moves along the parabolic trajectory.
Louis can choose different starting speeds and different directions for his first and second jump.
Of course, Louis must not attempt to pass through the wall, although it is allowed to touch it passing through the hole, this does not change the trajectory of the jump. The jumper is not allowed to pass through both holes in a single jump.
Find out, what must be the maximal starting speed of the Louis so that he could fulfil the exercise. That is, find the minimum strength (in terms of starting speed) Louis must have in order to pass through the holes in exactly two jumps.
First line is an integer T denoting the number of testcases.
Each testcase contains eight real numbers, separated by spaces and/or line feeds. They designate b1, t1, b2, t2, l, ds, df and g.
T <= 200
All numbers are in range from 10-2 to 103, t1≥ b1 + 10-2, t2≥ b2 + 10-2..
For each line of the input file output the smallest possible maximal speed the jumper must have to fulfil the exercise. If it is impossible to fulfil it, output -1. Your answer must be accurate up to 10-4.
2 0.3 1.0 0.5 0.9 1.7 1.2 2.3 9.8 0.6 0.8 0.6 0.8 2.4 0.3 1.5 0.7
5.2883 1.3127
Info: 本題輸出為浮點數,絕對或相對誤差 1e-4 以下視為正確
Migrated from old NTUJ.
sgu, Author: Andrew Stankevich, Resource: Petrozavodsk Summer Trainings 2003
No. | Testdata Range | Score |
---|