Scorched Earth
Time limit1sMemory limit256 MB
Given a fixed firing angle, wind, and both tank positions, compute the smallest launch speed up to 300 m/s that lands the shell on the target.
- Level
Medium4 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
General Arne Heisveis has nothing to do. The Norwegian defence budget was cut again and again, so his office is empty of work, and the generals now spend the whole day on an old computer game called Scorched Earth. Arne is competitive but bad at the game, so he wants a program that does the arithmetic for him.
A match is a duel between two tanks, and the only weapon is a small missile. The players fire in turn, each choosing an angle and an initial speed. The initial speed can never be negative and can never exceed m/s. While the missile flies, gravity pulls it down with and the wind gives it a constant acceleration along the x-axis.
Arne always finds an angle that clears every mountain on the battlefield, so the terrain is not part of the input. The speed is what he needs. If the tank sits at , the firing angle is degrees and the initial speed is , then after seconds the missile is at
where is the acceleration from the wind. The shot hits the opponent at when and hold at the same time .
Input
The first line has the number of test cases (). Each of the next lines has six real numbers , , , , , . Your tank is at and the opponent's tank is at , measured in meters, with and . The wind accelerates the missile along the x-axis by , with . The angle Arne chose is degrees, with . An angle fires along the increasing x-axis, and fires straight up.
Output
Print one line for each test case. If an initial speed between and m/s hits the opponent, print that speed with exactly 5 digits after the decimal point. If several speeds hit, print the smallest one. If no speed in that range hits, print impossible.