Problem 558
Angle Between Clock Hands
Easy · 10 pts · Math
Problem
Given a time H:M on an analog clock, find the smaller angle in degrees between the hour hand and the minute hand. The minute hand moves 6 degrees per minute. The hour hand moves 30 degrees per hour and also creeps forward 0.5 degrees per minute, so at H:M it points at 30 × (H mod 12) + 0.5 × M. Take the absolute difference d and answer min(d, 360 - d). The answer is always a multiple of 0.5; print it with exactly one digit after the decimal point.
Input
A single line with two integers H and M.
Output
Print the smaller angle with exactly one decimal place.
Constraints
1 <= H <= 12; 0 <= M <= 59
Example input
12 30
Example output
165.0
Explanation
At 12:30 the minute hand is at 180 degrees and the hour hand at 0 + 15 = 15 degrees. The difference is 165, which is smaller than 360 - 165, so the answer is 165.0.