ZOJ 3876 May Day Holiday 蔡勒公式
Description
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 题意:给你年份,每年5月1到5月5为固定休息日,但4月30,29有可能是礼拜六天,此时假期加2,5月6,7同理。问你此年份这段时间的长假能是多少
题解:用蔡勒公式判断这一天是星期几就好了
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=;
const int MAX=;
const int MOD=;
const int INF=;
const double EPS=0.00000001;
typedef long long ll; int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int main()
{
int d,c,w,y,m,n,T,ans;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
ans=;
y=n%;c=n/; m=;d=;
w=((y+y/+c/-*c+*(m+)/+d-)%+)%;
if (w==) ans+=;
else if (w==) ans++; m=;d=;
w=((y+y/+c/-*c+*(m+)/+d-)%+)%;
if (w==) ans+=;
else if (w==) ans++; printf("%d\n", ans);
}
return ;
}
代码
ZOJ 3876 May Day Holiday 蔡勒公式的更多相关文章
- 水题 ZOJ 3876 May Day Holiday
题目传送门 /* 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: */ #include <cstdio> #include <iostream> ...
- URAL 2048 History 蔡勒公式
HistoryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.acti ...
- HDU 6112 今夕何夕 蔡勒公式
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6112题意:中文题目 分析:关键点在与如何计算一个日期是星期几,这个可以通过蔡勒公式来计算.基姆拉尔森计 ...
- HDU 6112.今夕何夕-蔡勒公式 (2017"百度之星"程序设计大赛 - 初赛(A)1005)
1005:今夕何夕 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Probl ...
- Project Euler 19 Counting Sundays( 蔡勒公式计算星期数 )
题意:在二十世纪(1901年1月1日到2000年12月31日)中,有多少个月的1号是星期天? 蔡勒公式:计算 ( year , month , day ) 是星期几 以下图片仅供学习! /****** ...
- 牛客多校第六场 G Is Today Friday? 蔡勒公式/排列
题意: 有一堆日期,这些日期都是星期五,但是数字被映射成了字母A~J,现在让你求逆映射,如果存在多种答案,输出字典序最小的那个. 题解: 用蔡勒公式解决关于星期几的问题. 对于映射,可以用笔者刚刚学会 ...
- ZOJ 3876 May Day Holiday
As a university advocating self-learning and work-rest balance, Marjar University has so many days o ...
- 牛客多校第六场G Is Today Friday?(吉姆拉尔森/蔡勒公式 + 思维)题解
题意: 给你\(A-J\)的字母组成的日期,形式为\(yyyy/mm/dd\).现给你\(n\)个这样的串\((n<=1e5)\),问你把字母映射成数字,并且使得所有日期合法且为星期五的最小字典 ...
- 2017"百度之星"程序设计大赛 - 初赛(A)-1001.小C的倍数问题(HDU6108) 1005.今夕何夕-蔡勒公式 (HDU6112)
补完题?不存在的. 这么久了,还是一条咸鱼,看一堆乱七八糟的东西,写一堆没用的水题,一点进步都没有,还是那么菜,菜的掉渣. 这个百毒之星初赛A还会写两道最简单的水题,初赛B一点也不会,菜的难过... ...
随机推荐
- SVN文件库移植(转)
SVN文件库移植(转) 分类: 项目管理2013-04-19 11:06 161人阅读 评论(0) 收藏 举报 公司以前用的SVN是安装在windows2003下,用了一年多,现在大家觉得很慢,强烈 ...
- winfrom 多线程 并发 和定时任务
static void Main(string[] args) { //多个线程修改同一个值,使用lock锁解决并发 for (int i = 0; i < 4; i++) { Task.Fac ...
- How To:利用frm和idb文件进行数据恢复.txt
在另外一个机器上准备测试数据,并传输到dbadb05机器的/mysql/backup/reco/位置下.开始尝试恢复数据一.使用mysqlfrm获取表结构信息及DDL语句. [mysql@dbadb0 ...
- buf.fill()
buf.fill(value[, offset[, end]][, encoding]) value {String} | {Buffer} | {Number} offset {Number} 默认 ...
- 2015 湘潭大学程序设计比赛(Internet)部分题解,其中有一个题与NYOJ1057很像,贪心过~~
仙剑奇侠传 祝玩的开心 ...
- Codeforces Round #355 (Div. 2)-B. Vanya and Food Processor,纯考思路~~
B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input s ...
- 百度音乐免费API接口
音乐分类: 1.新歌榜,2.热歌榜,11.摇滚榜,12.爵士,16.流行21.欧美金曲榜,22.经典老歌榜,23.情歌对唱榜,24.影视金曲榜,25.网络歌曲榜 说明:百度music web版全接口h ...
- POJ 1127_Jack Straws
%: 对于二维向量p1=(x1,y1),p2=(x2,y2),定义内积p1⋅p2=x1x2+y1y2,外积p1×p2=x1y2−y1x2,则判断点q是否在线段p1−p2上: 先利用外积判断q是否在直线 ...
- 洛谷——P1044 栈
P1044 栈——卡特兰数 题目背景 栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表. 栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈) ...
- ibatis中isNotNull与isNotEmpty区别
isNotNull:参数不能为null,空的可以的 isNotEmpty:参数不能为null和空 那什么是空?比如String类型 String a = ""; a就是空