ZOJ Problem Set - 3177
Priestess of the Moon (PotM) is a very interesting hero in the game Defense of the Ancients (DotA). Here is the official description of PotM:
She has a very powerful skill named Elune's Arrow. When she uses this ability, she fires an arrow to a location with deadly precision, dealing large damage and stunning the first unit it strikes. A powerful skill, but hard to manage, because the enemy never stands still waiting for your arrow, and you can't change the angle after you fires the arrow. For the sake of simplicity, you can assume that the enemy's body area is a circle with radius r0, the effective range of your arrow is also a circle with radius r1, and the enemy always runs in a straight line. Now, PotM is standing at (x1, y1), while the enemy's position is (x0, y0). The enemy's speed in both x and y directions can be represent by a vector (dx, dy). So, after t minutes, the enemy's position will be (x0+dx*t, y0+dy*t). The speed of PotM's arrow is v. If the effective range of the arrow touches the enemy's body area, it will be considered a strike, just like the collision of two circles. Now PotM wants to strike the enemy as soon as possible, could you help her to determine the time which the arrow takes to strike the enemy?
The first line of the input contains a single number T (T <= 100), indicating the number of cases.
Each case consists of 5 lines, and each line contains the following decimal numbers:
Note: the initial distance between PotM and the enemy will be larger than r0+r1.
For each case, output the least time (in minutes) PotM needs to strike the enemy(accurate up to 4 decimal places). If PotM cannot strike the enemy, just output "Impossible" in one line.
2 0.0 0.0 4.0 0.0 1.0 0.0 1.0 1.0 2.0 0.0 0.0 300.0 400.0 -3.0 -4.0 1.0 1.0 5.0
Author: YANG, Kete
Contest: The 9th Zhejiang University Programming Contest