Advertisement
konchin_shih

a263

Apr 30th, 2023
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from sys import stdin
  2.  
  3. def isLeap(y):
  4.     return (y%4==0 and y%100!=0) or y%400==0
  5.  
  6. month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  7. # from 0/1/1
  8. def day_since_epoch(y, m, d):
  9.     ret = d + (y-1)*365
  10.     ret += (y-1)//4 - (y-1)//100 + (y-1)//400
  11.  
  12.     for i in range(1, m):
  13.         ret += month[i]
  14.         if i==2 and isLeap(y):
  15.             ret += 1
  16.  
  17.     return ret
  18.  
  19. line = 0
  20. y1, m1, d1, y2, m2, d2 = [0]*6
  21. for s in stdin:
  22.     line += 1
  23.     if line&1:
  24.         y1, m1, d1 = map(int, s.split())
  25.         continue
  26.     y2, m2, d2 = map(int, s.split())
  27.     ans1 = day_since_epoch(y1, m1, d1)
  28.     ans2 = day_since_epoch(y2, m2, d2)
  29.  
  30.     if ans1 > ans2:
  31.         ans1, ans2 = ans2, ans1
  32.  
  33.     print(ans2 - ans1)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement