# ZOJ 3876 May Day Holiday Caille formula

Source: Internet
Author: User

H-may Day Holiday

Description

As a university advocating self-learning and Work-rest balance, Marjar University have so many days of rest, including Holi Days and weekends. Each weekend, which consists of Saturday and Sunday, was 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 could day holiday are a five-day vacation from could 1st to May 5th. Due to Saturday or Sunday is adjacent to the could day holiday, the continuous vacation could be as long as nine days in R Eality. For example, the could day in was Friday so the continuous vacation was only 5 days (could 1st to May 5th). And the Sunday so the continuous vacation are 6 days (April 30th to May 5th). In the, the Monday and vacation are 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 could day in dif Ferent years. Can you help him?

Input

There is multiple test cases. The first line of input contains an integer indicating the number of the T test cases. For each test case, there is a integer y (1928 <= y <= 9999) in one line, indicating the year of Edward ' s q Uery.

Output

For each case, print the number of the days of the continuous vacation in the.

Sample Input
`3201520162017`
Output
`569Test instructions: Give you year, May January-May 5 for a fixed day of rest, but April 30,29 may be six days, this time holiday plus 2, May 6,7 the same. Ask you what this year's long vacation could be`
`Solving the puzzle: using Caille formula to judge the day of the week is good.`
`#include <map>#include<Set>#include<cmath>#include<queue>#include<cstdio>#include<vector>#include<string>#include<cstring>#include<iostream>#include<algorithm>#pragmaComment (linker, "/stack:102400000,102400000")using namespacestd;Const intn=1010;Const intmax=151;Const intMod=1000000007;Const intinf=1000000000;Const Doubleeps=0.00000001; typedefLong Longll;intRead () {intx=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}intMain () {intD,c,w,y,m,n,t,ans; scanf ("%d", &T);  while(t--) {scanf ("%d", &N); Ans=5; Y=n% -; c=n/ -; M=4;d = -; W= ((y+y/4+c/4-2*c+ -* (m+1)/Ten+d-1)%7+7)%7; if(w==0) ans+=2; Else if(w==6) ans++; M=5;d =6; W= ((y+y/4+c/4-2*c+ -* (m+1)/Ten+d-1)%7+7)%7; if(w==6) ans+=2; Else if(w==0) ans++; printf ("%d\n", ans); }    return 0;}`
Code

ZOJ 3876 May Day Holiday Caille formula

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.