Mock CCC '14 J3 - Clock Hands

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
2014 Mock CCC by Alex and Timothy

Alice had just dug up an old time capsule that she had buried in her backyard many years ago. Inside, she discovered an exquisite clock from when she was a young girl. When she buried the clock, she had removed the batteries so that the hands would remain in that position forever. This was done so she could remind her future self of the exact time at which she met her eternal love interest — Bob. Unfortunately, all but the 12 o'clock marking had worn away over the years. With a protractor handy, Alice is determined to find out the exact time that Bob came into her life.

Measuring the hour hand from the centre of the clock, Alice determined that it was H degrees clockwise from the 12 o'clock marking. Alice then measured the angle of the minute hand, determining that it was M degrees clockwise relative to the hour hand. Finally, she measured the second hand, determining that it was S degrees clockwise relative to the minute hand. The three angle measurements will all be non-negative real numbers greater than or equal to 0, but less than 360. You may assume that the angles will yield valid times.

Input Specification

Three lines, containing the three values H, M, and S.

Output Specification

Output the time, in the format HH:MM:SS, where HH (1 \le HH \le 12) is the number of hours, MM (0 \le MM < 60) is the number of minutes, and SS (0 \le SS < 60) is the number of seconds. These values each must be padded to two digits with leading zeros. Round the time to the nearest second.

Sample Input 1

195
345
180

Sample Output 1

06:30:00

Sample Input 2

90.066667
270.733333
47.200000

Sample Output 2

03:00:08

Explanation

The following diagrams depict Alice's clock for the examples above. Orange is the hour hand, black is the minute hand, and red is the second hand.


Comments

There are no comments at the moment.