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. Go Redis 开发

    redigo库来实现redis的操作:https://github.com/gomodule/redigo Redis常用操作 示例代码: package main import ( "gi ...

  2. ScreenOS地址转换

    目录 1. NAT-src 1.1 来自DIP池(启用PAT)的NAT-src 1.2 来自DIP池(禁用PAT)的NAT-src 1.3 来自DIP池(带有地址变换)的NAT-src 1.4 来自出 ...

  3. 1.mysql导论

    虽然之前用过mysql一年多,但大多只是会用,深入了解的不多.所以想利用平时时间 系统的总结总结. 一.什么是数据库:(数据库软件)     1).什么是数据库(软件):数据库(DB:DataBase ...

  4. 【codevs3031】最富有的人(字典树)

    网址:http://codevs.cn/problem/3031/ 这是蒟蒻写的第一道字典树……听说出市选题的神犇要出字符串,于是就赶紧滚去学了学(然而高精度算字符串算法?) 简单来说,字典树就是把一 ...

  5. 如何使用REST请求风格

    REST:即 Representational State Transfer.(资源)表现层状态转化.是目前最流行的一种互联网软件架构. 它结构清晰.符合标准.易于理解.扩展方便, 所以正得到越来越多 ...

  6. HBase学习1(hbase基础)

    认识NoSQL NoSQL:泛指非关系数据库(Not only SQL) NoSQL两重要特征:使用硬盘和把随机存储器作为存储载体 NoSQL分类(按照存储格式) 1)键值(Key-Value)存储数 ...

  7. java collection接口源码

    package java.util; 02. 03./* 04.* 1.Collection接口是集合继承关系中的根接口(root interface),有些集合允许重复元素, 05.* 有些集合有序 ...

  8. hibernate学习(3)

    0 列表功能实现 1 表与表之间关系回顾 (1)一对多(客户和联系人) (2)多对多(用户和角色) 2 hibernate 一对多操作 (1)一对多映射配置 (2)一对多级联保存 (3)一对多级联删除 ...

  9. html5学习笔记(forms)

    forms api 规范 新的输入型控件新的函数和特性 新增input 类型 <input type="tel"> tel 电话号码email 电子邮箱URL 网页ur ...

  10. 洛谷P1027 Car的旅行路线

    洛谷P1027 Car的旅行路线 题目描述 又到暑假了,住在城市A的Car想和朋友一起去城市B旅游.她知道每个城市都有四个飞机场,分别位于一个矩形的四个顶点上,同一个城市中两个机场之间有一条笔直的高速 ...