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

算法思路:先计算分针的角度。再计算时针的角度。取两个角度的差的绝对值,再取锐角。

posted on 2020-02-09 09:40  Sempron2800+  阅读(199)  评论(0编辑  收藏  举报