diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-17 20:29:47 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-17 20:29:47 +0700 |
commit | 1f9cdd4cce664439625f13da1baf894190b7e9a6 (patch) | |
tree | 2d1af656692ece87c83c4f57196b5f3825d475b7 /codechef/longcook.py | |
parent | 82e6cf7d1046d6cee16f7e8b044ec33e7ec6c4b7 (diff) | |
download | cp-1f9cdd4cce664439625f13da1baf894190b7e9a6.tar.gz |
Thank you Corona for giving me some time to do this
Diffstat (limited to 'codechef/longcook.py')
-rwxr-xr-x | codechef/longcook.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/codechef/longcook.py b/codechef/longcook.py new file mode 100755 index 0000000..d57d9f2 --- /dev/null +++ b/codechef/longcook.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +from calendar import isleap +from datetime import datetime + +OVERLAP = [datetime(i or 400, 2, 7).weekday() + in ([4] if isleap(i or 400) else [4, 5]) for i in range(400)] +OOP = sum(OVERLAP) + + +def longcook(start, end): + delta = end - start + if delta <= 0: return 0 + return delta//400*OOP + sum(OVERLAP[y % 400] + for y in range(start, start + delta%400)) + + +for t in range(int(input())): + m1, y1 = map(int, input().split()) + m2, y2 = map(int, input().split()) + print(longcook(y1+(m1>2), y2+(m2!=1))) |