当前位置:网站首页>Openjudge: perpetual calendar
Openjudge: perpetual calendar
2022-07-28 05:36:00 【Programmer system】
describe
Given month, year and day , Ask for the day of the week . It is known that 2020 year 11 month 18 It's Wednesday . in addition , This topic has a year 0 year , This is different from the real chronology
Input
The first line is n(n <=30), Express n Group data
Next n That's ok , Each row is a set of data .
Three integers per row y,m,d, Each represents the year , month , Japan .(-1000000<=y<=1000000)
If this year is 2017 year , Then go ahead 2016 year ,2015 year .... Count to 2 year ,1 year , Further on is 0 year ,-1 year ,-2 year .....
Output
For each set of data , Output day of the week , Days of the week are used separately
"Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday" Express
If the month and date are illegal , Output "Illegal"
The sample input
6 2017 2 29 2017 13 2 0 1 1 -2 3 4 2017 10 18 2015 12 31
Sample output
Illegal Illegal Saturday Wednesday Wednesday Thursday
Code
def judge_week(year, month, day):
lst1 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
lst2 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
date = days = 0
lst_days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
if month in [1, 3, 5, 7, 8, 10, 12]:
if day < 1 or day > 31:
print('Illegal')
return
elif month == 2:
if (year % 4 == 0) and (year % 100 != 0) or year % 400 == 0:
if day < 1 or day > 29:
print('Illegal')
return
else:
if day < 1 or day > 28:
print('Illegal')
return
elif month in [4, 6, 9, 11]:
if day < 1 or day > 30:
print('Illegal')
return
else:
print('Illegal')
return
if year>=1: #1 year 1 month 1 Sunday is Monday
for i in range(1,year):
if (i % 4 == 0) and (i % 100 != 0) or i % 400 == 0:
days += 366
else:
days += 365 # Add up the whole year
if ((year % 4) == 0) and ((year % 100) != 0) or ((year % 400) == 0):
for i in range(month-1):
date +=lst1[i]
else:
for i in range(month-1):
date +=lst2[i] # Accumulated whole month
total=date+day+days
x=total % 7
print(lst_days[x])
else:
for i in range(year+1, 1):
if (i % 4 == 0) and (i % 100 != 0) or i % 400 == 0:
days += 366
else:
days += 365 # Add up the whole year
if ((year % 4) == 0) and ((year % 100) != 0) or ((year % 400) == 0):
for i in range(month - 1,12):
date += lst1[i]
else:
for i in range(month - 1,12):
date += lst2[i] # Accumulated whole month
total = date - day + 1 + days
x = total % 7
print(lst_days[(8-x)%7])
n = int(input())
for i in range(n):
year, month, day = map(int, input().split())
judge_week(year, mon, day)
边栏推荐
- Example of main diagram of paper model
- 导出excel,生成多个sheet页,并命名
- SimpleDateFormat线程不安全和DateTimeFormatter线程安全
- openjudge:病人排队
- Mabtis(一)框架的基本使用
- C language: realize the simple function of address book through structure
- Export excel, generate multiple sheet pages, and name them
- How should programmers keep warm when winter is coming
- Personal summary of restful interface use
- 使用深度学习训练图像时,图像太大进行切块训练预测
猜你喜欢

论文写作用词

Long和Integer如何进行比较,为什么报错

自定义Json返回数据

Redis 之布隆过滤器

restFul接口使用个人总结

How about ink cloud?

SSLError

ByteBuffer. Position throws exception illegalargumentexception

Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions

VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard
随机推荐
restFul接口使用个人总结
Export excel, generate multiple sheet pages, and name them
使用navicat或plsql导出csv格式,超过15位数字后面变成000(E+19)的问题
JVM note 4: Memory Model
C language: realize the simple function of address book through structure
How to compare long and integer and why to report errors
BeanUtils. Copyproperties cannot copy different list sets problem solving lists.transform function
Docker deploy mysql5.7.35
Framework step by step easy-to-use process
JVM篇 笔记3:类加载与字节码技术
JUC笔记
openjudge:大小写字母互换
repackag failed: Unable to find main class
docker 部署 mysql5.7.35
子父线程交互
openjudge:找出全部子串位置
多模块打包:程序包:xxx不存在
(dark horse) MySQL beginner advanced notes (blogger lazy dog)
自定义Json返回数据
多线程进阶:锁的策略