HDU 2133 模拟
来源:互联网 发布:阿里布达年代祭百度云 编辑:程序博客网 时间:2024/05/19 20:41
What day is it
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4419 Accepted Submission(s): 1294
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<cstdio>#include<iostream>using namespace std;int ok(int n){ if((n%4==0&&n%100!=0)||(n%400==0)) return 1; return 0;}int main(){int y=0,m=0,d=0;int tian[2][31]= {{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}}; char rr[8][30]= {{"Sunday"},{"Monday"},{"Tuesday"},{"Wednesday"},{"Thursday"},{"Friday"},{"Saturday"}};while(scanf("%d%d%d",&y,&m,&d)!=EOF){if((ok(y)==0&&m==2&&d==29)||m>12||d>tian[ok(y)][m]||m==0||d==0||y==0) { printf("illegal\n"); continue; } int sum=0; for(int i=1;i<y;i++) { if(ok(i)) sum+=366; else sum+=365; sum%=7; } for(int i=1;i<m;i++) { sum+=tian[ok(y)][i]; sum%=7; } sum+=d; sum%=7; printf("%s\n",rr[sum]);}return 0;}
0 0
- HDU 2133 模拟
- 【几何模拟】hdu 3286
- hdu 1020 Encoding(模拟)
- hdu 1303 Doubles(模拟)
- hdu 4020 模拟
- HDU **** 暴力模拟
- HDU 4068 模拟
- HDU 4121 模拟
- 【模拟】HDU 4134
- HDU-1279 模拟
- HDU-1035 模拟
- HDU-1283 简单模拟
- HDU-1263 模拟
- hdu 4140 模拟
- hdu 1034 #模拟
- hdu 4194#模拟
- hdu 4350 Card 模拟
- hdu 4393 贪心+模拟
- CentOS 7 firewalld使用简介
- JAVA实现二维数组中的查找(《剑指offer》)
- Centos 7 中修改ssh端口号的方法
- 数字排列(等差数列计算)
- 关于二进制文件储存格式
- HDU 2133 模拟
- svn can't open file db/txn-current-lock permission denied问题
- jQuery实现点击页面获得当前点击元素的id
- TCP 的那些事儿(下)
- 1014. Waiting in Line (30) 模拟银行排队
- httpget
- 用Javascript获取页面元素的位置
- C语言中可变参数的实现原理
- SYN Flood攻击防范技术白皮书