ZOJ 3876 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 之所以记下这个题,是想提醒一下自己写关于闰年的题目时一定要用闰年规则进行判断,别直接除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 ;
}
ZOJ 3876 May Day Holiday的更多相关文章
- 水题 ZOJ 3876 May Day Holiday
题目传送门 /* 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: */ #include <cstdio> #include <iostream> ...
- ZOJ 3876 May Day Holiday 蔡勒公式
H - May Day Holiday Description As a university advoc ...
- ZOJ 3876 JAVA
题意: 输入年份,求五一假期一共放多少天假.五一假期默认5天,如果5月1号星期一,那么它之前有星期六星期天两天假期, 假期总长度就变成5+2,五一假期结束第二天也需要判断是不是假期. 思路: 使用Ja ...
- May Day Holiday
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Status Practic ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- 【BZOJ 3876】【AHOI 2014】支线剧情
http://www.lydsy.com/JudgeOnline/problem.php?id=3876 这道题每条支线的意思是每条边... 那么每条边的下界设为1就行了. 这样建出一个DAG,每条边 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
随机推荐
- Spring Boot简单环境搭建
#### 一.创建一个简单的Maven项目 使用`Maven`,通过导入`Spring Boot`的`starter`模块,可以将许多程序依赖的包自动导入到工程中.使用`Maven`的`parent ...
- git的使用(一)
git —version 展示git的版本 tanya ~$ git --version git version 2.22.0 最小配置 git config —global user.na ...
- JavaScript的event对象
JavaScript的event对象中 event.target指代的是:触发事件的元素 event.currentTarget指代的是:事件绑定的元素 <!DOCTYPE html> & ...
- 使用富文本编辑器Kindeditor
今天在做需求的时候,遇到有一个字段,需要保存带有格式的内容,决定使用富文本框编辑器Kindeditor来实现,解决方法如下: 登录官网下载控件包: http://kindeditor.net/down ...
- iview自定义实现多级表头
最近更新: 2018-07-19 注意:最新版iview已经提供多级表头功能 参考 原理:利用多个Table组件通过显示和隐藏thead和tbody来拼接表格(较粗暴) html <div st ...
- JAVA的初体验
jdk的地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html 第一步:找到相应的JAVA SE版本,点击down ...
- 面试java后端面经_1
1 自我介绍(建议提前准备:没准备的可以这样说:来自某学校 姓名 专业 学的啥 为啥学 自己陆陆续续开发的项目 毕业将近 找工作 在哪看到贵公司的招聘 准备了啥 大概这样) 例子:您好!我是来自XXX ...
- Ubuntu 17 安装Chrome浏览器
1.进入下载文件存放目录 cd Downloads 2.下载chrome文件 2.1 32位使用如下命令 wget https://dl.google.com/linux/direct/google- ...
- R语言中如何找出在两个数据框中完全相同的行(How to find common rows between two dataframe in R?)
I would like to make a new data frame which only includes common rows of two separate data.frame. ex ...
- Python模块之pexpect
一.pexpect模块介绍 Pexpect使Python成为控制其他应用程序的更好工具.可以理解为Linux下的expect的Python封装,通过pexpect我们可以实现对ssh,ftp,pass ...