2015 浙江省赛 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的更多相关文章
- 2017浙江省赛 H - Binary Tree Restoring ZOJ - 3965
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3965 题目: iven two depth-first-search ...
- 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 ...
- 2015安徽省赛 H.数7
http://xcacm.hfut.edu.cn/problem.php?id=1212 模拟大发 #include<iostream> #include<cstdio> #i ...
- 2015 浙江省赛B Team Formation (技巧,动归)
Team Formation For an upcoming programming contest, Edward, the headmaster of Marjar University, is ...
- 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H Skiing【拓扑排序,关键路径】
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H Skiing In this winter holiday, Bob has a plan for skiing at the moun ...
- 2013年省赛H题
2013年省赛H题你不能每次都快速幂算A^x,优化就是预处理,把10^9预处理成10^5和10^4.想法真的是非常巧妙啊N=100000构造两个数组,f1[N],间隔为Af2[1e4]间隔为A^N,中 ...
- 2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂
2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂 [Problem Description] 已知\(f(n)=3\cdot f(n ...
- 2018 ACMICPC上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节) 链接:https://ac.nowcoder.co ...
- 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 ...
随机推荐
- oracle 字典表查询
1.oracle 字典表查询 /*显示当前用户*/ show user 在sql plus中可用,在pl sql中不可用 /*查看所有用户名*/ select username,user_id,cre ...
- 算法总结之 在两个排序数组中找到第K小的数
给定两个有序数组arr1 和 arr2 ,再给定一个int K,返回所有的数中第K小的数 要求长度如果分别为 N M,时间复杂度O(log(min{M,N}),额外空间复杂度O(1) 解决此题的方法跟 ...
- 使用 Apache Spark 让 MySQL 查询速度提升 10 倍以上
转: https://coyee.com/article/11012-how-apache-spark-makes-your-slow-mysql-queries-10x-faster-or-more ...
- Javascript的this用法---阮一峰
Javascript的this用法 作者: 阮一峰 日期: 2010年4月30日 this是Javascript语言的一个关键字. 它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用.比 ...
- 【转】数据库获得当前时间getdate()
CONVERT(nvarchar(10),count_time,121): CONVERT为日期转换函数,一般就是在时间类型 (datetime,smalldatetime)与字符串类型(nchar, ...
- elasticsearch中如何手动控制全文检索结果的精准度
1.为帖子数据增加标题字段 POST /forum/article/_bulk{ "update": { "_id": "1"} }{ &q ...
- js运算符、关键字、保留字、转义字符
- js抽象工厂模式
抽象工厂模式,提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类. 抽象工厂允许客户使用抽象的接口来创建一组相关产品,而不需要知道或关心实际生产出的具体产品是什么.这样客户就可以从具体 ...
- JS实现百叶窗效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Jedis使用过程中踩过的那些坑
1. 一个 大坑:若实例化 JedisShardInfo 时不设置节点名称(name属性),那么当Redis节点列表的顺序发生变化时,会发生“ 键 rehash 现象” 使用BTrace追踪redis ...