Defying Gravity
Time limit2sMemory limit512 MB
Given n point masses around the origin, list every line through the origin that avoids all satellites and keeps the total force radial along the whole path.
- Level
Medium7 of 10
- Topics
- String matching, Geometry, Math
- Solved
- No attempts yet
Problem
Planet Oz is located at the origin of the two-dimensional Euclidean plane. Elphaba wants to show everyone that her powers lie far beyond the laws of physics. To do this, she wants to take off from Oz and fly away along some straight line to infinity and beyond.
Oz has satellites revolving around it. For each satellite, its polar coordinates and mass are known. Here, the planet and satellites are treated as points. is the radial distance from Oz to the -th satellite, and is the polar angle between the satellite and a fixed reference direction, measured in arc seconds.
Elphaba is at the point and has mass . The -th satellite is at the point . The satellite attracts Elphaba with a force directed from Elphaba toward the satellite. The force is proportional to Elphaba's mass and the satellite's mass , and inversely proportional to the squared distance between them. The exact force that the -th satellite applies to Elphaba is:
Here, is the universal gravitational constant, whose value does not matter for this problem.
Forces from different satellites add up directly. The total force on Elphaba is .
Elphaba wants a flight direction that does not pass through any satellite and is not changed by the satellites at any moment. In other words, the force must be collinear with at every point on her trajectory.
Find all possible directions for Elphaba's flight.
Input
The first line contains a single integer (), the number of satellites.
Each of the following lines contains three integers , , and (, , ), the polar coordinates and mass of the -th satellite.
It is guaranteed that no two satellites have the same polar angle .
Output
Output a sorted list of real numbers () denoting the polar angles, in arc seconds, of all possible flight directions. An answer is correct if the absolute or relative error of every number is at most . The answer always contains at most directions.
Hint
One arc second (written 1′′) is one sixtieth of one arc minute (1′), and one arc minute is one sixtieth of one degree (1°). So , , and , meaning 129600 arc seconds make a full turn.

In the first example, the first satellite is at A(1; 0) and the second is at B(−1; 0). The only possible flight directions in the picture are the ones with polar angles 90° = 32400'' and 270° = 97200''.