HDU 2133 What day is it
来源:互联网 发布:淘宝淘气值怎么看 编辑:程序博客网 时间:2024/05/01 19:57
What day is it
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2705 Accepted Submission(s): 792
Problem Description
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
#include <iostream>using namespace std;int main(){ int d,m,y; int month[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}}; while(cin>>y>>m>>d) { int sum=d; int leap=y%4==0&&y%100!=0||y%400==0; for(int i=0;i<m;i++) sum+=month[leap][i]; if(m==2) { if(leap==0&&d>28) { cout<<"illegal"<<endl; continue; } if(leap&&d>29) { cout<<"illegal"<<endl; continue; } } if((m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&d>31) { cout<<"illegal"<<endl; continue; } if((m==4||m==6||m==9||m==11)&&d>30) { cout<<"illegal"<<endl; continue; } if(m==0||d==0) { cout<<"illegal"<<endl; continue; } for(int i=1;i<y;i++) { int leap=i%4==0&&i%100!=0||i%400==0; sum+=((365+leap)%7); } int k=sum%7; if(k==1) cout<<"Monday"<<endl; else if(k==2) cout<<"Tuesday"<<endl; else if(k==3) cout<<"Wednesday"<<endl; else if(k==4) cout<<"Thursday"<<endl; else if(k==5) cout<<"Friday"<<endl; else if(k==6) cout<<"Saturday"<<endl; else cout<<"Sunday"<<endl; }}
- 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?
- 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 is it
- hdu 2133 What day is it
- What day is it 2133
- 杭电Hdu 2133 What day is it
- HDU 2133 What day is it(日期转换)
- hdu 1308 What Day Is It?
- hdoj 2133 What day is it
- Linux下Socket编程
- ACMore-1488(数位DP)
- VS 生成事件文件拷贝
- 中文标点UTF-8编码
- 企业证书打包
- HDU 2133 What day is it
- Bubble(15)
- Bubble(16)
- NSNotification的用法
- 1889_Ones(同余)
- 腾讯2012实习生笔试题2+答案解析
- Tortoise SVN安装
- 学科前沿技术(让用户来决定Windows任务管理器的CPU占用率)
- MFC消息映射机制