1

# 1154. Day of the Year

Input: date = "2019-01-09"
Output: 9

mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

# 判斷閏年
def isLeap(n):
return (n%4==0 and n%100!=0) or n%400==0

def dayOfYearII(year, month, day):
return sum(mdays[:month])+day + (month>2 and isLeap(year))

class Solution:
def dayOfYear(self, date: str) -> int:
year, month, day = map(int, date.split('-'))
return dayOfYearII(year, month, day)

# 1185. Day of the Week

Input: day = 31, month = 8, year = 2019
Output: "Saturday

mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def isLeap(n):
return (n%4==0 and n%100!=0) or n%400==0

# 計算日期是從元年元月元日算起的幾幾天
def daysFromZeroYear(year, month, day):
leaps = year//4-year//100+year//400 - (month<=2 and isLeap(year))
return 365*(year-1) + sum(mdays[:month])+day + leaps

class Solution:
def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
weekdays= ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
return weekdays[daysFromZeroYear(year, month, day)%7]

# 補題: zerojudge- a263: 日期差幾天

mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def isLeap(n):
return (n%4==0 and n%100!=0) or n%400==0

# 計算日期是從元年元月元日算起的幾幾天
def daysFromZeroYear(year, month, day):
leaps = year//4-year//100+year//400 - (month<=2 and isLeap(year))
return 365*(year-1) + sum(mdays[:month])+day + leaps

while True:
try:
y1, m1, d1 = map(int,input().split())
y2, m2, d2 = map(int,input().split())
print(abs(daysFromZeroYear(y1, m1, d1)-daysFromZeroYear(y2, m2, d2)))
except:
break