#P4483. [BJWC2018] 神奇的钟点
[BJWC2018] 神奇的钟点
Description
One day, Xiao L saw three clocks showing , , and . Xiao L noticed that each time is in the form , where is the hour and is the minute, and none of them is on the hour (i.e., , ).
Recalling a lesson about ratios, also represents a ratio with value . Then Xiao L discovered something magical: adding these three times yields , which is also a valid time that is not on the hour (note the hour must be less than ). Its corresponding ratio is exactly equal to the sum of the ratios , , and of the three times!
Now Xiao L wants to know: among all triplets of times that satisfy this magical property, sorted in lexicographic order, what is the -th smallest?
Input Format
The input contains only a single positive integer .
Output Format
Output the -th smallest triplet that satisfies the magical property described in the statement, with the three times separated by a space; see the sample output. If the answer does not exist, output -1.
65432
01:08 03:40 13:52
1
00:01 00:01 00:01
58
00:01 00:02 00:01
2000000000
-1
Hint
【Sample Explanation】
Note that the times may be identical.
【Constraints】
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号