Hide

Problem A
Hickory Dickory Dock

Hickory dickory dock, the mouse ran up the clock.
The clock struck one, the mouse ran down,
hickory dickory dock.

Hickory dickory dock, the mouse ran up the clock.
The clock struck two, the mouse said “Boo!”
hickory dickory dock.

Hickory dickory dock, the mouse ran up the clock.
The clock struck three, the mouse said “Whee!”
Hickory dickory dock.

Hickory dickory dock, the mouse ran up the clock.
The clock struck four, the mouse said “No more!”
Hickory dickory dock.

A paraphrase of the verse presumes there was a spoonful of grated cheese sitting on top the clock, and that is what attracted mice. It reads “The MICE ran up the clock. The clock struck one, and the rest ran away with the spoon.” That was at 1:00. But the mice do not run away quickly enough if the hour is other than 1:00. In those cases, successive strikes of the clock each clobber yet another mouse. The devious owner of the clock realizes he has devised a better mouse trap, and replaces the spoon with more cheese. The remaining mice do return within a few minutes and the cycle repeats. Given the starting time and total number of mice, at what time was the last mouse struck? (After being struck, mice are fed to the cat who fiddled between her snacks.) Strikes occur one per second while counting the hour starting at the hour, and one at each quarter, half, and three-quarter hour.

Let’s say we are starting at 11:45, just before the three-quarter strike, and are looking for when the last of, say 22 mice will be struck:

  • The first mouse will be "struck" at 11:45:00.

  • Starting at noon, twelve mice will be struck, one per second, through 12:00:11.

  • One mouse each will be struck at: 12:15:00, 12:30:00, and 12:45:00.

  • Another mouse will be struck at 1:00:00 as the clock strikes for the hour.

  • Three more mice will be struck at: 1:15:00, 1:30:00, and 1:45:00.

  • The last two mice will be struck at 2:00:00 and 2:00:01.

Input

There will be three lines of input, each containing an integer. The first line will contain an integer representing the starting hour 1-12. The second line will contain an integer representing the starting minute 0-59. The third line will contain an integer representing the number of mice 1-1000. The simulation will always start right on the minute, and if the clock would strike at that time, it will indeed do so, as in the example above.

Output

If one mouse is struck each time the clock strikes, at what time will the last mouse be struck? Don’t worry if it is not on the same date. Print the time as "hh:mm:ss" with leading 0’s as needed so that hours, minutes, and seconds are each two digits.

Sample Input 1 Sample Output 1
11
45
22
02:00:01
Sample Input 2 Sample Output 2
12
0
2
12:00:01

Sample Input 3 Sample Output 3
1
1
1
01:15:00

Please log in to submit a solution to this problem

Log in