606第九周周三赛 E - What day is it今天星期几
来源:互联网 发布:车辆数据 编辑:程序博客网 时间:2024/06/07 06:39
E - What day is it
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me what day it is ?
Input
There are multiply cases.
One line is one case.
There are three integers, year(0<year<10000), month(0<=month<13), day(0<=day<32).
One line is one case.
There are three integers, year(0<year<10000), month(0<=month<13), day(0<=day<32).
Output
Output one line.
if the date is illegal, you should output "illegal". Or, you should output what day it is.
if the date is illegal, you should output "illegal". Or, you should output what day it is.
Sample Input
2007 11 17
Sample Output
Saturday
其实我不太懂为什么不用考虑题目给的条件,难道0年1月1日是星期日吗?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
#include<stdio.h>#include<iostream>using namespace std;string a[7]= {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};int s[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};int IsLeap(int y){ if((y%4==0&&y%100!=0)||y%400==0) return 1; else return 0;}int judge(int y,int m,int d){ if(y>0&&y<10000&&m>0&&m<13&&d>0) { if(m==2) return d<=s[2]+IsLeap(y); else return d<=s[m]; } else return 0;}int day(int y,int m,int d){ int r=0; for(int i=1; i<y; i++) r+=365+IsLeap(i); s[2]+=IsLeap(y); for(int i=1; i<m; i++) r+=s[i]; s[2]=28; return r+d;}int main(){ int y=0,m=0,d=0; while(scanf("%d%d%d",&y,&m,&d)!=EOF) { if(judge(y,m,d)==0) cout<<"illegal"<<endl; else { cout<<a[day(y,m,d)%7]<<endl; } } return 0;}
0 0
- 606第九周周三赛 E - What day is it今天星期几
- hdu 1308 What Day Is It? (算星期几)
- HDU 2133 What day is it(给定日期求星期几)
- HDU2133:What day is it
- What day is it 2133
- hdu1308 What Day Is It
- HDU2133 What day is it
- 【hdu2133】What day is it
- 知道年月日就可以计算那一天是星期几(What day is today?)
- What day is it hdu2133(终于AC)
- HDU 2133 - What day is it
- HDU 2133 What day is it
- HDU 2133 What day is it
- hdu 2133 What day is it
- HDU:2133 What day is it
- hdu 2133 what day it is?
- 杭电 1308 What Day Is It?
- zoj 1256 What Day Is It?
- android 按钮背景颜色以及按下颜色设置
- CSD(Canonic signed digit)正则有符号数
- keepalived 详解
- python,学校成员类的例子,老师和学生(python class父类与子类之间的联系与逻辑)
- PostgreSQL学习手册(系统表)
- 606第九周周三赛 E - What day is it今天星期几
- [kuangbin带你飞]专题一 简单搜索 E - Find The Multiple poj 1426
- PostgreSQL学习手册(系统视图)
- OFFICE2016仅安装需要的组件
- 万万不要自己发明语法
- Java中可变长参数的使用及注意事项
- 【坑】当java的环境变量配置正确还是不能运行eclipse的情况
- 带参数的单例模式遇到的问题
- RSA算法原理