Ecliptic
Time limit2sMemory limit256 MB
Given the axial tilt and the launchpad's latitude, find the first time after the reported equator crossing when the launchpad is closest to the ecliptic plane.
- Level
Medium7 of 10
- Topics
- Math, Geometry, Implementation, Simulation
- Solved
- No attempts yet
Problem
The <>, an unmanned spacecraft, is stationed in the Northern Hemisphere at latitude degrees and is ready to take off at any moment. The <> is to be put into a solar orbit, so it must be launched at a moment when the launchpad is nearest to the ecliptic plane.
The planet revolves around its sun along a circular orbit. The ecliptic plane is the plane containing this orbit. The planet is a sphere rotating around its axis. The angle between the planet's axis and the normal to the ecliptic plane is degrees. The planet makes a full turn around its axis in 24 hours.
The control station is located on the planet's equator, at the same longitude as the <>. It crosses the ecliptic plane every 12 hours. At HH:MM:SS the control station reports crossing the ecliptic plane, and afterwards the control station and the <> are separated from each other by the ecliptic plane. Find the first moment after this report when the <> will be as close to the ecliptic plane as possible.
Input
The first line of the input file contains a single integer , the number of tests (). Each of the following pairs of lines contains a description of a consecutive test.
The first line of a test description contains two real numbers and . The number is the angle between the rotation axis of the planet and the perpendicular line to the ecliptic plane, in degrees; the number is the latitude of the spacecraft location, in degrees (). Both real numbers are given with no more than five digits after the decimal point.
The second line contains the time of the incoming message from the control station. The time is given in the 24-hour format HH:MM:SS, where HH is the number of hours from 0 to 23, MM is the number of minutes from 0 to 59, and SS is the number of seconds from 0 to 59. Each of the three numbers contains strictly two digits, with possible leading zeroes.
Output
The output file must contain answers to the tests in the order of their appearance in the input, one answer per line.
An answer to a test is the nearest moment in time when the spacecraft can be launched. The time must be printed in the same format as the time in the message from the control station. The printed time must differ from the accurate answer by no more than one second.