Armageddon
Time limit1sMemory limit128 MB
Compute the time left before firing a missile can no longer deflect two asteroid pieces to miss Earth, given current distance, separation angle, and both speeds.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Geometry, Simulation
- Solved
- No attempts yet
Problem
An asteroid is heading straight for Earth. We can see only part of it — the rest is hidden behind the Sun — so its size and speed are unknown, and we must plan for the worst case.
Fortunately we have missiles. When a missile strikes the asteroid, the asteroid splits into two pieces that fly apart symmetrically, separating at a total angle of degrees. Each piece therefore leaves the asteroid's original line of flight at an angle of and then travels in a straight line.
Earth is a circle of radius km centered at the origin. The asteroid travels straight toward the origin. We fire a missile from the point on Earth's surface nearest the asteroid (distance from the origin) straight along the asteroid's path; the missile moves at a constant speed, and the asteroid keeps its constant speed until impact.
If the missile strikes the asteroid while it is still at distance from the origin, the two pieces miss Earth exactly when . Firing later means a smaller and less separation, so there is a last possible moment to fire. Given the asteroid's current distance, the separation angle, and the two speeds, report how many seconds remain before it is too late to fire.
Input
The first line contains the number of test cases . Each of the next lines describes one scenario with four numbers:
- — the asteroid's distance from Earth's center in kilometers (),
- — the angle in degrees at which the two pieces separate (),
- — the asteroid's constant speed in kilometers per second (),
- — the missile's constant speed in kilometers per second ().
Output
For each scenario, print Data Set x: on its own line, where is the scenario number starting from . On the next line print the number of seconds remaining before it is too late to fire, rounded to two decimal places. If less than seconds remain, print Oh no! instead. Separate consecutive scenarios with a single blank line.