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 之所以记下这个题,是想提醒一下自己写关于闰年的题目时一定要用闰年规则进行判断,别直接除4!!!
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<cmath>
#define ls (u<<1)
#define rs (u<<1|1)
#define maxn 1010
#define ll long long
#define INF 1e9
using namespace std;
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
int d[maxn],c[maxn];
int main(){
int T;
scanf("%d",&T);
while(T--){
int n,num;
scanf("%d",&n);
int a = ;
for(int i=;i<=n;i++){
if((i%== && i%!=) || (i%==)){//记得要用闰年规则判断
a ++;
}
}
int b = n - - a;
num = a* + b*;//把从1928年5.1到n年5.1的天数算出来就行
num %= ;
num += ;
num %= ;
if(num == || num == ){
printf("6\n");
}
else if(num == ){
printf("9\n");
}
else if(num>=&&num<=){
printf("5\n");
}
}
return ;
}

最新文章

  1. 安卓智能POS终端手持机PDA应用仓库出入库,移库,盘点,销售开单系统
  2. 命名空间“System.Web”中不存在类型或命名空间名称“HttpUtility”。是否缺少程序集引用?
  3. C # 数据绑定(1)——将DataTabel的data添加ListView
  4. Java程序员的日常—— 基于类的策略模式、List&lt;?&gt;与List、泛型编译警告、同比和环比
  5. 关于ruby重构的过程中去除不必要的format
  6. Delphi Unable to invoke Code Completion due to errors in source code
  7. CCNP路由实验(1) -- EIGRP
  8. Java中的流程控制
  9. CSS中的ul与li样式详解 list-type
  10. java自动化-关键字驱动在junit接口自动化的应用
  11. Ubuntu16.04 将其他磁盘挂载到 /home, 解决/home空间不足
  12. python中的基础2
  13. 关于PHP程序员技术职业生涯规划
  14. 客户端负载均衡Feign之四:Feign配置
  15. 解决jquery绑定click事件出现点击一次执行两次问题
  16. Flutter 数据模型创建
  17. 【JMeter】初识JMeter(1)
  18. AI贪吃蛇前瞻——基于Dijkstra算法的最短路径问题
  19. eject命令详解
  20. R语言外部数据读取

热门文章

  1. HC-08 BLE资料
  2. Zabbix在 windows下监控网卡
  3. [译]Python中的异步IO:一个完整的演练
  4. 01-Spring Security框架学习--入门(二)
  5. Hyper-V虚拟机上安装Ubuntu16.04/Ubuntu18.04.2LTS,搭建GitLab
  6. print(&#39;&#39;, end=&#39;&#39;)
  7. Java枚举类型 enum
  8. requestAnimationFrame 兼容方案
  9. Java并发编程实战笔记—— 并发编程3
  10. 60701BMP彩色图像转化为灰度及二值图像