NYOJ 219 An problem about date

来源:互联网 发布:智百威软件怎么用 编辑:程序博客网 时间:2024/05/16 08:34

An problem about date

时间限制:2000 ms  |  内存限制:65535 KB
难度:2
描述

acm的iphxer经常忘记某天是星期几,但是他记那天的具体日期,他希望你能写个程序帮帮他。

 

输入
每行有三个整数 year,month,day,日期在1600年1月1日到9600年1月1日之间;
输出
输出对应的星期,用一个整数表示;(星期一到星期六用1-6表示,星期日用0表示)
样例输入
2011 3 61949 10 12011 4 11945 8 15
样例输出
0653
 #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){    int a,b,c;    while(~scanf("%d%d%d",&c,&b,&a))    {if(b<=2)    {b+=12;    c--;    }int w=(a+2*b+3*(b+1)/5+c+c/4+-c/100+c/400+1)%7;printf("%d\n",w);    }}        


0 0