H - May Day Holiday

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<map>
#include<string.h>
#include<cstdio>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int d;
scanf("%d",&d);
if(d==)
{
printf("5\n");
}
else if(d>)
{
int i;
int s=;
for(i=;i<=d;i++)
{
if(i%==||(i%==&&i%!=))
{
s+=;
}
else s++;
}
int we=(+s)%;
if(we==) printf("6\n");
else if(we==) printf("9\n");
else if(we==) printf("6\n");
else printf("5\n"); }
else if(d<)
{
int i;
int s=;
for(i=d;i<;i++)
{
if(((i+)%==)||((i+)%==&&(i+)%!=))
{
s+=;
}
else s++; } int we=(+s)%;
if(we==) printf("9\n");
else if(we==) printf("6\n");
else if(we==) printf("6\n");
else printf("5\n");
}
}
return ;
}

2015 浙江省赛 H - May Day Holiday的更多相关文章

  1. 2017浙江省赛 H - Binary Tree Restoring ZOJ - 3965

    地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3965 题目: iven two depth-first-search ...

  2. 2015 浙江省赛 Beauty of Array (思维题)

    Beauty of Array Edward has an array A with N integers. He defines the beauty of an array as the summ ...

  3. 2015安徽省赛 H.数7

    http://xcacm.hfut.edu.cn/problem.php?id=1212 模拟大发 #include<iostream> #include<cstdio> #i ...

  4. 2015 浙江省赛B Team Formation (技巧,动归)

    Team Formation For an upcoming programming contest, Edward, the headmaster of Marjar University, is ...

  5. 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H Skiing【拓扑排序,关键路径】

    2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛  H Skiing In this winter holiday, Bob has a plan for skiing at the moun ...

  6. 2013年省赛H题

    2013年省赛H题你不能每次都快速幂算A^x,优化就是预处理,把10^9预处理成10^5和10^4.想法真的是非常巧妙啊N=100000构造两个数组,f1[N],间隔为Af2[1e4]间隔为A^N,中 ...

  7. 2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂

    2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂 [Problem Description] ​ 已知\(f(n)=3\cdot f(n ...

  8. 2018 ACMICPC上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节) 链接:https://ac.nowcoder.co ...

  9. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)

      Ace of Aces Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a mysterious organization c ...

随机推荐

  1. Python 列表List的定义及操作

    # 列表概念:有序的可变的元素集合 # 定义 # 直接定义 nums = [1,2,3,4,5] # 通过range函数构造,python2 和python3 版本之间的差异: # python3 用 ...

  2. ubuntu 的mysql 安装过程和无法远程的解决方案

    ubuntu 的mysql 安装过程和无法远程的解决方案 安装完mysql-server启动mysqlroot@ubuntu:# /etc/init.d/mysql start (如果这个命令不可以, ...

  3. nginx的理解

    1.静态HTTP服务器 首先,Nginx是一个HTTP服务器,可以将服务器上的静态文件(如HTML.图片)通过HTTP协议展现给客户端. 配置: 2.反向代理服务器 什么是反向代理? 客户端本来可以直 ...

  4. 用javascript实现的验证码

    <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">     ...

  5. 算法总结之 数组的partition调整

    给定一个有序数组arr, 调整arr使得这个数组的左半部分没有重复元素且升序,而且不用保证右边是否有序 分区就ok了 u区是 无重复且升序的  u是这个区域的最后位置,初始u=0 i做从左到右的遍历, ...

  6. 在环境变量里设置VI中TAB缩进

    终端上的tab键默认是缩进8个空格的(记住8个空格不等于一个tab, tab和空格不是一个概念) 一般设置vim的tab(制表符)的缩进的时候都这样:set tabstop=4 ” 表示让tab的宽度 ...

  7. 《Think in Java》(六)访问权限控制

    类访问权限:public,default(包访问权限的类,在包外可以调用该类的static成员) 类属性访问权限:public,protected,default,private

  8. php/oracle: 解析oracle表中的NCLOB,CLOB字段里面的内容

    php/oracle: 解析oracle表中的NCLOB,CLOB字段里面的内容 假如你的字段名是:passenger_info 字段类型是:NCLOB/CLOB,在读表的时候,需要将 passeng ...

  9. docker安装---CentOS_7

    操作系统要求 要安装Docker,您需要64位版本的CentOS 7.步骤:   卸载旧版本 Docker的旧版本被称为docker或docker-engine . 如果这些已安装,请卸载它们以及关联 ...

  10. FunnelWeb 开源Blog引擎介绍

    FunnelWeb is an open source blog engine, built by developers for developers. Instead of fancy quotes ...