#C8732. Clock Angle Calculator
Clock Angle Calculator
Clock Angle Calculator
Given a time on a 12-hour analog clock, compute the smaller angle between the hour and minute hands.
The hour hand moves continuously, and its angle in degrees is given by:
\( \text{hour_angle} = 30 \times \left( (h \mod 12) + \frac{m}{60} \right) \)
The minute hand moves in discrete increments, and its angle is:
\( \text{minute_angle} = 6 \times m \)
The angle between the two hands is the absolute difference between these two angles. However, if this angle is greater than \(180^\circ\), the smaller angle is its supplementary \(360^\circ - \text{angle}\).
Your task is to calculate and output the smaller angle between the two hands, rounded to two decimal places.
inputFormat
The input consists of a single line with two integers separated by a space:
- h (an integer in the range 0 to 12, where 12 is treated as 0 in calculations)
- m (an integer in the range 0 to 59)
For example: 3 15
outputFormat
Output the smaller angle between the hour and minute hands in degrees, rounded to two decimal places. For instance, for input 3 15
, the output should be 7.50
.
3 15
7.50
</p>