当前位置:网站首页>openjudge:万年历
openjudge:万年历
2022-07-28 05:18:00 【编程器系统】
描述
给定年月日,求星期几。已知2020年11月18日是星期三。另外,本题有公元0年,这个和真实的纪年不一样
输入
第一行是n(n <=30),表示有n组数据
接下来n行,每行是一组数据。
每行三个整数y,m,d,分别代表年,月,日。(-1000000<=y<=1000000)
若今年是2017年,则往前就是2016年,2015年....一直数到2年,1年,再往前就是0年,-1年,-2年.....
输出
对每组数据,输出星期几,星期几分别用
"Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday" 表示
如果月份和日期不合法,输出"Illegal"
样例输入
6 2017 2 29 2017 13 2 0 1 1 -2 3 4 2017 10 18 2015 12 31
样例输出
Illegal Illegal Saturday Wednesday Wednesday Thursday
代码
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年1月1日为星期一
for i in range(1,year):
if (i % 4 == 0) and (i % 100 != 0) or i % 400 == 0:
days += 366
else:
days += 365 #累加整年数
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] #累加整月数
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 # 累加整年数
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] # 累加整月数
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)
边栏推荐
- 集合框架的操作使用
- When SQL queries the list, the data is inconsistent twice, and limit is automatically added
- oracle查看锁表语句、解锁方法
- Digital twin solutions inject new momentum into the construction of chemical parks
- The most detailed installation of windows10 virtual machine, install virtual machine by hand, and solve the problem that the Hyper-V option cannot be found in the home version window
- ECCV22 最新54篇论文主图整理
- Mysql基本查询
- PC端-bug记录
- 凛冬已至,程序员该怎么取暖
- block yandex bot
猜你喜欢

蒙特卡罗方法求解圆周率π并用turtle画点,以及完成进度条问题

CentOS7安装MySQL5.7

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

How to compare long and integer and why to report errors

JUC笔记

Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address

Edge calculation kubeedge+edgemash

Tomato timing dimming table lamp touch chip-dlt8t10s-jericho

MySQL date and time function, varchar and date are mutually converted

测试开发---自动化测试中的UI测试
随机推荐
图像增强——MSRCR
深度学习医学图像模型复现
【单例模式】懒汉模式的线程安全问题
visio如何快速生成相同的图案,生成图像矩阵
【idea插件神器】教你如何使用IDEA一键set实体类中所有属性
JVM篇 笔记4:内存模型
Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
ByteBuffer.position 抛出异常 IllegalArgumentException
New arrow function in ES6
Performance test classification
Response < t > class
C language: addition and deletion of linked list in structure
子父线程交互
New modularity in ES6
Scanf function of input and output function in C language
多模块打包:程序包:xxx不存在
Mabtis(一)框架的基本使用
LocalDateTime去掉T,JSONField失效
Flask Development & get/post request
Offline loading of wkwebview and problems encountered