1 class Solution:
 2     def numberOfDays(self, Y: int, M: int) -> int:
 3         dic1 = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
 4         dic2 = {1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
 5         leapYear = False
 6         if Y % 4 == 0 and Y % 100 != 0:
 7             leapYear = True
 8         elif Y % 400 == 0:
 9             leapYear = True
10         if leapYear:
11             return dic2[M]
12         else:
13             return dic1[M]

 

posted on 2019-07-14 00:05  Sempron2800+  阅读(148)  评论(0编辑  收藏  举报