Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

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

3
2015
2016
2017

Output

5
6
9
#include<bits/stdc++.h>
using namespace std;
int run(int y)
{
if(y%==&&y%!=||y%==)
return ;
return ;
}
int day(int y)
{
int sum = ;
int D=;
for(int i = ;i <y;i++)
{
sum+=;
if(run(i))
{
sum++;
}
}
sum+=;
if(run(y))
sum++;
D=(D+sum)%;
return D;
} int main()
{ int t;
cin>>t;
while(t--)
{
int y;
cin>>y;
int s=day(y);
int ans = ;
if(s==)//周五
ans = ;
else if(s==||s==)//周一 和 周六
ans=;
cout<<ans<<endl;
}
}

May Day Holiday的更多相关文章

  1. 【UOJ #29】【IOI 2014】holiday

    http://uoj.ac/problem/29 cdq四次处理出一直向左, 一直向右, 向左后回到起点, 向右后回到起点的dp数组,最后统计答案. 举例:\(fi\)表示一直向右走i天能参观的最多景 ...

  2. 水题 ZOJ 3876 May Day Holiday

    题目传送门 /* 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: */ #include <cstdio> #include <iostream> ...

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

  4. 第十二届浙江省大学生程序设计大赛-May Day Holiday 分类: 比赛 2015-06-26 14:33 10人阅读 评论(0) 收藏

    May Day Holiday Time Limit: 2 Seconds Memory Limit: 65536 KB As a university advocating self-learnin ...

  5. HDU 4118 Holiday's Accommodation

    Holiday's Accommodation Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 200000/200000 K (Jav ...

  6. hdoj 1827 Summer Holiday【强连通分量&&缩点】

    Summer Holiday Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  7. HDU 4118 树形DP Holiday's Accommodation

    题目链接:  HDU 4118 Holiday's Accommodation 分析: 可以知道每条边要走的次数刚好的是这条边两端的点数的最小值的两倍. 代码: #include<iostrea ...

  8. Summer Holiday(强联通入度最小点)

    Summer Holiday Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  9. IOI2014 day2 task4 Holiday

    题目 题目链接 大意:从左到右有\(n\)个城市,一开始在城市\(start\),每一天有两种选择: 前往相邻的城市. 访问当前城市(每个城市只能访问一次),访问城市\(i\)可以获得\(attrac ...

随机推荐

  1. java String 怎么看里面有几个指定字符

    我现在有一个String 字符串,我想看一下这个字符串里有几个指定的字符,比如指定字符是div求解 public class Main { public static void main(String ...

  2. goahead 移植

    1.网上下载goahead-3.1.-0-src.tgz包 2.解压 tar -zxvf goahead-3.1.-0-src.tgz 3.编译 cd goahead-3.1.-0 make CC=a ...

  3. [转]TOMCAT原理以及处理HTTP请求的过程、ContextPath ServletPath

    一.TOMCAT 1 - Tomcat Server的组成部分 <Server>     <Service>         <Connector/>        ...

  4. iOS开发UITableViewCell的选中时的颜色设置

    1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...

  5. poj2676解题报告

    题意:有一个9*9的格子 分成了9个3*3的小子格,一些位置上的已有一些数字..现在要求你把没有数字的位置填上数,要求这个数没有出现在这个位置所在的行.列以及所在的子格 分析: 那么我们对于所有的未填 ...

  6. 基于visual Studio2013解决算法导论之048红黑树

     题目 红黑树 解决代码及点评 // 红黑树.cpp : 定义控制台应用程序的入口点. // #include <stdio.h> #include <stdlib.h> ...

  7. hpu第五届acm比赛

    vijos P1211生日日数   描述 CCC老师的生日是YY年MM月DD日,他想知道自己出生后第一万天纪念日的日期(出生日算第0天). 格式 输入格式 从文件的第一行分别读入YY,MM,DD其中1 ...

  8. Log4Net五步走

    本文不是教你全面了解log4net,本文只是希望教会你按步就班,照糊芦画瓢般就会用log4net1,引入log4net.dll组件2,建立一个配置文件两种方法,一种是在Web.Config或App.C ...

  9. 分析一个socket通信: server/client

    分析一个socket通信: server/client1 server 1. 创建一个server_socket文件,并绑定端口,然后监听端口 (socket, bind, listen) 2. 查询 ...

  10. Qt实现QQ好友下拉列表(用QListView实现,所以还得定义它的Model)

    偶然发现Qt有个控件可以实现下拉列表,所以就试着实现一下类似QQ面板的下拉列表,这里主要实现几个功能: 1.可以删除列表中图标 2.可以像qq一样的,把某个分组下的图标转移到另外的分组 3.添加分组 ...