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. Android源码目录分析【转】

    本文转载自:http://blog.csdn.net/backgarden_straw/article/details/8050783 在学习Android的过程中,学习写应用还好,一开始不用管太多代 ...

  2. Centos 一次卸载多个RPM包

    rpm 不支持通配符,可以使用 xargs来接收多个变量 示例,一次性卸载所有 erlang先关的rpm包: rpm -qa | grep erlang | xargs rpm -e --nodeps

  3. Python 集合set概念和操作

    # 集合 # 概念 # 无序的, 不可随机访问的, 不可重复的元素集合 # 与数学中集合的概念类似,可对其进行交.并.差.补等逻辑运算 # 分为可变集合和非可变集合 # set # 为可变集合 # 增 ...

  4. [Android]动态加载/热部署框架汇总

    1.DroidPlugin 用途:动态加载 使用案例:360手机助手 GitHub地址:https://github.com/Qihoo360/DroidPlugin ppt介绍:https://gi ...

  5. eclipse异常关了,tomcat如何关

    eclipse异常关了,tomcat如何关 ? 1.bin文件夹下面有的shutdown.bat.双击即可! 2.在任务管理器里面关闭,看到javaw.exe关闭也行.            

  6. myeclipse 10 j安装了JDK1.7,java编译器无法选择到1.7的问题

    java程序编写,在eclipse中会自动编译,编译的版本在preferrence-->java-->compiler选择具体版本,这时你写程序时自动编译用的jdk就是这个版本的jdk,这 ...

  7. 关于CKEDITOR的一些小问题

    <textarea  name="tMessage" ></textarea> <script type="text/javascript& ...

  8. .gitignore 无效

    利用.gitignore过滤文件,如编译过程中的中间文件,等等,这些文件不需要被追踪管理. 现象: 在.gitignore添加file1文件,以过滤该文件,但是通过Git status查看仍显示fil ...

  9. 汇编笔记 RETF

    assume cs:code stack segment db 16 dup(0) stack ends code segment start: mov ax,stack;将定义字形数据送入AX mo ...

  10. python正则表达式同时匹配多个关键字(多关键字匹配)

    网上翻了很多文章...居然没有一个有用的..倒是找到一篇java的,但java的正则表达式和python的还有点不同. 那篇java的文章是用"[keywd1]|[keywod2]|[key ...