LA 2729

LA 2729 - The Solar System

 * http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=2729

Summary
Given are some data about two planets in the same solar system. Use Kepler's laws to calculate the location of one of the planets in a given moment.

Explanation
From the third law we may compute the period of revolution of the second planet. Now, we compute the time left in the last revolution. We have to find a point on the ellipse that (the part of the ellipse swept by the line planet-sun / ellipse area) = (time left / period of revolution). This involves some calculus. The answer can either be computed directly, or you can find the right point using binary search on the perimeter of the ellipse.

Gotchas

 * Be careful, with all those floating point numbers around it's easy to make precision errors.

Input
10 5 10 10 5 10 10 5 10 20 10 10 0 0 0 0 0 0

Output
Solar System 1: 10.000 0.000 Solar System 2: -17.525 4.819