ZOJ 3876 May Day Holiday(水)

来源:互联网 发布:社交软件 日语怎么说 编辑:程序博客网 时间:2024/05/17 22:43

思路:水题...


#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;int a[10010];void init(){a[2016] = 6;for(int i=2017;i<10010;++i){if((i%400==0||i%100!=0)&&i%4==0){a[i] = (a[i-1]+2)%7;}else a[i] = (a[i-1]+1)%7;}for(int i=2015;i>=1810;--i){if(((i+1)%400==0||(i+1)%100!=0)&&(i+1)%4==0){a[i] = (a[i+1]-2+7)%7;}else a[i] = (a[i+1]-1+7)%7;}}int main(){    //freopen("in.txt","r",stdin);    //freopen("out.txt","w",stdout);int ca;init();scanf("%d", &ca);while(ca--){int n;scanf("%d", &n);//cout<<"a[n]:"<<a[n]<<endl;if(a[n]==0) puts("9");else if(a[n]==6) puts("6");else if(a[n]==1) puts("6");else puts("5");}        return 0;}

Description

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 integer y (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


0 0
原创粉丝点击