1 class Solution: 2 def angleClock(self, hour: int, minutes: int) -> float: 3 m_angle = minutes * 6 4 h_angle = (hour + minutes / 60) * 6 * 5 if hour != 12 else (minutes / 60) * 6 * 5 5 diff = abs(m_angle - h_angle) 6 diff = min(diff,360-diff) 7 return diff
算法思路:先计算分针的角度。再计算时针的角度。取两个角度的差的绝对值,再取锐角。