1999-2000
ACM North Central Regional Programming Contest
Problem 4
— Clock Angles
The angle between the hour and minute hands of an analog clock is always between 0 and 180 degrees, inclusive. For example, at 12:00 the angle between the hands is 0 degrees. At 6:00 the angle is 180 degrees, and at 3:00 the angle is 90 degrees. In this problem you are to find the angle between the hands of a clock for an arbitrary time between 12:00 and 11:59.
The input data will contain multiple test cases. Each test case will consist of two numbers. The first number specifies the hour, and will be greater than 0 and less than or equal to 12. The second number specifies the number of minutes, and will be in the range 0 to 59. Two numbers, each of which is 0, will follow the last test case.
For each test case, display the time in the usual form and the smallest angle formed by the hands, accurate to one fractional digit. The output should be similar to that shown in the sample below.
12 0
12 30
6 0
3 0
0 0
At
12:00 the angle is 0.0 degrees.
At
12:30 the angle is 165.0 degrees.
At
6:00 the angle is 180.0 degrees.
At
3:00 the angle is 90.0 degrees.