Good Times Vs. Bad Times
Practice
3.8 (4 votes)
Mathematics
Dynamic programming
Easy Medium
Number theory
Problem
8% Success 5758 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Chandan, our problem moderator, recently got a digital clock as a birthday present. A digital clock shows time in the format \(HH:MM:SS\), where \(HH, MM, SS\) represents hours , minutes, and seconds respectively. It is a \(24\) hour clock and so the day starts at \(00:00:00\) hours while it ends at \(23:59:59\).

We all know how punctual and particular Chandan is about each and every second of his life. One sunny day, at his leisure, when he was fiddling with his clock, he discovered that a second was good for him if none of the \(HH, MM\; and \; SS\) at that second was divisible by the same prime number, i.e. it is bad if all of them give 0 as a remainder when divided by the same prime number.

Given a time of a day, Chandan now wants to count the number of good times and bad times from that instance till the end of the day \((23:59:59)\).

Input & Output:

The first line of the input contains the number of test cases T. T test cases follow and each test contains a line HH MM SS, the time from which he wants to count till the end of that day.

For each test case, output a ratio in the format "\(B:G\)" (quotes for clarity), where G is the the number of good seconds and B is the number of bad seconds for Chandan. Express the ratio \(B : G\) in its lowest terms, i.e. it should not have any common factor.

Constraints

\(1 \le T \le 10 ^ 5\)
\(00\)\(HH\) < \(24\)
\(00\)\(MM\) < \(60\)
\(00\)\(SS\) < \(60\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
4 votes
Tags:
C++GCDMathNumber Theory
Points:30
3 votes
Tags:
MathematicsEasy-MediumGreatest common divisorNumber Theory
Points:30
48 votes
Tags:
RecursionGreatest common divisorEasy-MediumReadyMathematicsApproved