题目
Given two numbers, hour and minutes. Return the smaller angle (in degrees) formed between the hour and the minute hand.
解题思路
时针和分针的夹角是5.5 * (hour * 60 + minutes) % 360
,然后取小于等于180度的角
代码
class Solution:
def angleClock(self, hour: int, minutes: int) -> float:
angle = 5.5 * (hour * 60 + minutes) % 360
return angle if angle <= 180 else 360 - angle