Given the time in hours and minutes, you need to calculate the angle between the hour hand and the minute hand.
Note :There can be two angles between the hour hand and minute hand, you need to print a minimum of two. Also, print the floor value of angle i.e. if the angle is 15.2, you need to print 15.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first and only line of each test case contains two integers H and M denoting the time in hours and minutes.
Output format:
For each test case, print the smaller angle between the hour hand and minute hand.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= H <= 12
0 <= M <= 59
Time Limit: 1 sec
2
6 30
8 55
15
62
For test case 1: when the time is 6:30 the two angles between the hour hand and the minute hand is 15 degree and 345 degrees. As 15 is the smallest so the ans is 15.
For test case 1: when the time is 8:55 the two angles between the hour hand and the minute hand is 62.5 degree and 297.5 degrees. As 62.75 is the smallest so the ans is 62.
2
3 30
12 0
75
0
Take a fixed time as a reference and then calculate the angle made by the hour hand and the minute hand with respect to this reference time. The difference between the two angles is the required angle.
O(1) per test case.
In the worst case, we are calculating the values using formulas.
O(1) per test case.
In the worst case, we are taking constant space.