By Gabriel Batista Galli, Mendelics Brazil
One of the big fields of research at the University of the South is Computational Astrophysics. In the most recent group assignment, it is asked to unravel the mysteries of a letter not known by many, by thankfully preserved by the History Museum of the university:
“April 27th, 1597
I've been studying some papers of Nicolaus Copernicus for a long time already and I've found a pretty interesting side note in the last pages of his De revolutionibus orbium coelestium. He wrote:
There's a huge number of exotic celestial bodies orbiting the Sun, just like the Earth does, and we are in a constant threat of imminent collision. Such event could eradicate every living being in our planet!
After reading such words, I started trying to figure out how to estimate the position of the planets along time. And I managed to find some formulae that can help! But no one believes the heliocentric model, so I'm sure no one's gonna trust any of this too. But I know you believe. You are the only one that can help me now, Galileo.
Initially, it could appear that every planet moves along a circular orbit around the Sun. But as math shows us, our star is actually one of the foci of the elliptical orbit these bodies describe (don't worry, how to calculate these angular anomalies is part of my discovery). Thus, I named perihelion the closest point an object gets to Sun and aphelion the farthest. Knowing these two coordinates and the orbital period of those bodies, we can follow these formulae and approximate their position after a given time since perihelion! There's a lot of math to do here, but I know you're good at it and together we can make it work!
First, we'll need the mean anomaly M = n × t of the body, where t is the number of days since perihelion and n is its mean motion, given by n = 2π / o. Here, o is the orbital period, also in days, of the celestial body. Second, we need to solve an equation that I've kindly given my name to (I am actually having a lot of trouble solving this one!): M = E − e × sin E, where E is the eccentric anomaly and e is the eccentricity of the orbit. M is a parameterization of time and E a parameterization of polar angle. These anomalies relate to where the body would be if it had a perfectly circular orbit (very eccentric, indeed)...
Regardless, now we just have to find the distance r = a × (1 − e × cos E) from the body to the Sun, a being the semi-major axis of the orbit, and the true anomaly θ of the body in order to get to its polar coordinate (r, θ) with respect to Sun. For the true anomaly, we have cos θ = (cos E − e) / (1 − e × cos E) and sin θ = (sin E × √(1 − e2)) / (1 − e × cos E).
Well... we finally know the polar coordinates of every planet around our star and of a potentially catastrophic celestial body. What we wanna know is if that body is currently inside or on the boundary of a triangle formed by any other three bodies of our Solar System. The Sun and some of our planets are so massive they can alter the orbit of the body and make it come directly to us, if it wasn't already (or eject it outta here, but who knows?). So if it is close enough, we are undoubtedly lost!
I am so worried, Galileo... I don't want this to be the end of our road! What can we do, if that is what this harmonically chaotic Mundi wants? If the worst happens, would you spend some of your last minutes with me?
With love, from the always yours,
Several lines make up a test case. The first one has an integer k representing the number of planets (2 ≤ k ≤ 105). The following k lines contain the description of each planet: four floating point numbers corresponding to the distance of perihelion dph and aphelion dap in kilometers from the Sun, orbital period o in days and the time t since the last perihelion, also in days (0 < dph ≤ dap ≤ 1010; 0 < o ≤ 105; 0 ≤ t < o), respectively. The last line contains the description of the feared celestial body, in the same format as a planet. Consider all objects in the input to be coplanar. Every floating point number will have at most 8 decimal places.
The output should be a single line containing “Certus, Kepler!” if Kepler and Galileo spent their last minutes together or “Harmonicus nihilominus!” otherwise (without the quotes).
|Input Sample||Output Sample|