H-may Day Holiday--zoj

Source: Internet
Author: User

H-May Day HolidayTime limit:$ MS Memory Limit:65536KB 64bit IO Format:%lld & Amp %llu SubmitStatus

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
569





The main calculation is April 29 is the day of the week:

#include <stdio.h> #include <string.h> #include <math.h>int t; int caculateweekday (int y,int m, int d); int judgeyear (int year), int judgedate (int year,int mouth,int day), int main () {long date;int year,day,mouth;int n,flag=0,i ; scanf ("%d", &n); for (i=1;i<=n;i++) {flag=0;scanf ("%ld", &date); year=date;mouth=4;day=29;t= Caculateweekday (Year,mouth,day) +1;switch (t) {case 1:case 2:case 3:case 4:printf ("%d\n", 5); Break;case 5:case 7:printf ( "%d\n", 6); Break;case 6:printf ("%d\n", 9); break;}} return 0;} int caculateweekday (int y,int m, int d) {    if (m==1| | m==2) {        m+=12;        y--;    }    int iweek= (d+2*m+3* (m+1)/5+y+y/4-y/100+y/400)%7;  


For more information on the calculation formula, see:

http://blog.csdn.net/chudongfang2015/article/details/51365866


H-may Day Holiday--zoj

Contact Us

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.