Broken clock
Time limit0.5sMemory limit512 MB
Given the clock-face angles of an hour hand and a minute hand in whole degrees, decide whether both can point that way at the same instant on a working clock.
- Level
Easy3 of 10
- Topics
- Math, Number theory, Implementation, Brute force
- Solved
- No attempts yet
Problem
Sangeon hurt his leg on his first day at the training camp, so he took the bus whenever he had to travel any distance. One day he looked at the analog clock mounted at the front of the bus and noticed that something was wrong with it. It pointed at a time that no working clock can show. Decide whether a clock is broken by looking only at the directions of its hour hand and minute hand.
On a working clock both hands point exactly at the 12 o'clock direction at 12:00. The hour hand makes one full turn every 12 hours and the minute hand makes one full turn every hour. Both move clockwise at a constant speed.
Input
The first line contains the angle of the hour hand and the angle of the minute hand as integers (). Both angles are measured clockwise from the 12 o'clock direction. For example, the 3 o'clock direction is and the 9 o'clock direction is .
Output
Print O on the first line if the two given angles can occur on a working clock, and X if they cannot.
Hint
An hour hand pointing at the 6 o'clock direction together with a minute hand pointing at the 12 o'clock direction is what a clock shows at exactly 6:00, so it is normal. An hour hand pointing at the 12 o'clock direction while the minute hand points at the 6 o'clock direction cannot occur on a working clock.