May Day Holiday
来源:互联网 发布:硕士论文淘宝代写 编辑:程序博客网 时间:2024/04/30 17:46
As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists of Saturday and Sunday, is a rest time in the Marjar University.
The May Day, also known as International Workers' Day or International Labour Day, falls on May 1st. In Marjar University, the May Day holiday is a five-day vacation from May 1st to May 5th. Due to Saturday or Sunday may be adjacent to the May Day holiday, the continuous vacation may be as long as nine days in reality. For example, the May Day in 2015 is Friday so the continuous vacation is only 5 days (May 1st to May 5th). And the May Day in 2016 is Sunday so the continuous vacation is 6 days (April 30th to May 5th). In 2017, the May Day is Monday so the vacation is 9 days (April 29th to May 7th). How excited!
Edward, the headmaster of Marjar University, is very curious how long is the continuous vacation containing May Day in different years. Can you help him?
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case, there is an integery (1928 <= y <= 9999) in one line, indicating the year of Edward's query.
Output
For each case, print the number of days of the continuous vacation in that year.
Sample Input
3201520162017
Output
569
集体团结把这题ac了。。
#include<iostream>#include<stdio.h>#include<string.h>#include<string>#include<math.h>#include<algorithm>using namespace std;int rn(int year){if(year%400==0 ||(year%4==0&&year%100!=0))return 1;else return 0;}struct Yea{bool run;int xq;};Yea Y[10000];int main(){int i;for(i=1928;i<=9999;i++){if(rn(i))Y[i].run=1;elseY[i].run=0;}Y[2015].xq=5;for(i=2014;i>=1928;i--){ if(Y[i].run==0 &&Y[i+1].run ) Y[i].xq=(Y[i+1].xq-2+7)%7;else Y[i].xq=(Y[i+1].xq-1+7)%7;}for(i=2016;i<=9999;i++){ if(Y[i].run) Y[i].xq=(Y[i-1].xq+2)%7; else Y[i].xq=(Y[i-1].xq+1)%7;}int T,year;while(cin>>T){while(T--){cin>>year;if(Y[year].xq==1)cout<<"9"<<endl;else if(Y[year].xq==2)cout<<"6"<<endl;else if(Y[year].xq==0 ||Y[year].xq==7)cout<<"6"<<endl;elsecout<<"5"<<endl;}}return 0;}
- May Day Holiday
- May Day Holiday
- ZOJ3876 May Day Holiday
- May Day Holiday
- May Day Holiday
- zoj 3876 May Day Holiday
- ZOJ 3876 May Day Holiday
- ZOJ 3876 May Day Holiday
- ZOJ 3876 May Day Holiday
- ACM-水题 May Day Holiday
- ZOJ 3876--May Day Holiday
- ZOJ 3876 May Day Holiday
- ZOJ - 3876-May Day Holiday
- ZOJ3876:May Day Holiday(浙江省赛2015)
- ZOJ Problem Set - 3876||May Day Holiday
- zoj3876 May Day Holiday(判断闰年)
- ZOJ 3876 May Day Holiday(水)
- H - May Day Holiday——ZOJ
- CentOS常用到的查看系统命令
- Android Action Bar 详解篇
- window 下安装 mongodb
- 霍夫变换详解
- java中的可见性修饰符
- May Day Holiday
- C++文件操作(一)
- 如何查看已安装的CentOS版本信息
- 杭电ACM第1002题(A + B Problem II)答案 java版
- CentOS 6.5下利用Rsyslog+LogAnalyzer+MySQL部署日志服务器
- 12th.浙江省省赛 G Lunch Time
- MFC学习总结 (67个技巧)
- FYSHOP OPENCART 主题模板 ABC-0430
- 借助Java静态变量,递归求阶乘和代码分享