Educational Codeforces Round 13 B. The Same Calendar 水题
B. The Same Calendar
题目连接:
http://www.codeforces.com/contest/678/problem/B
Description
The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.
Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (https://en.wikipedia.org/wiki/Leap_year).
Input
The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.
Output
Print the only integer y' — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.
Sample Input
2016
Sample Output
2044
Hint
题意
给你一个年y,让你找到大于y的某一年,使得和y这一年的日期一模一样。
题解:
其实就是经过的天数%7==0
而且那一年的平闰年和这一年是一样的。
代码
#include<bits/stdc++.h>
using namespace std;
bool check(int p)
{
if(p%400==0)return 1;
if(p%4==0&&p%100!=0)return 1;
return 0;
}
int main()
{
int y;
scanf("%d",&y);
int ans = y+1;
int p=(365+check(ans))%7;
while(p!=0||check(y)!=check(ans))
p=(p+365+check(++ans))%7;
cout<<ans<<endl;
}
Educational Codeforces Round 13 B. The Same Calendar 水题的更多相关文章
- Educational Codeforces Round 13 D. Iterated Linear Function 水题
D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...
- Educational Codeforces Round 13 C. Joty and Chocolate 水题
C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...
- Educational Codeforces Round 13 A. Johny Likes Numbers 水题
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...
- Educational Codeforces Round 14 A. Fashion in Berland 水题
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...
- Educational Codeforces Round 4 A. The Text Splitting 水题
A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...
- Codeforces Educational Codeforces Round 3 B. The Best Gift 水题
B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...
- Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题
A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
随机推荐
- mysql修改表的存储引擎(myisam<=>innodb)【转】
修改表的存储引擎myisam<=>innodb 查看表的存储引擎mysql> show create table tt7;+-------+--------------------- ...
- python 根据输入的内容输出类型
类型判断 from functools import singledispatch import numbers from collections import abc from collection ...
- python 写入execl记录
记录代码中关于写execl的操作 # 创建execl workbook = xlwt.Workbook(encoding='utf8') # 创建样式实例 style = xlwt.XFStyle() ...
- win10 操作配置备忘
让程序自动启动 如果想要实现应用程序在所有的用户登录系统后都能自动启动,就把该应用程序的快捷方式放到"系统启动文件夹"里: C:\ProgramData\Microsoft\Win ...
- 洛谷P2002消息扩散
传送门啦 这个题就是tarjan强连通分量与入度的例题了. 思路: 利用缩点的思想,先预处理一下所有的强连通分量,然后把每个强连通分量内的所有节点看做一个节点,然后处理一张新图,然后检查每个点的入度, ...
- 【Netty官方文档翻译】引用计数对象(reference counted objects)
知乎有关于引用计数和垃圾回收GC两种方式的详细讲解 https://www.zhihu.com/question/21539353 原文出处:http://netty.io/wiki/referenc ...
- python_Appium测试环境搭建
Android环境搭建 移动端Appium环境部署比Web的selenium环境稍微复杂一些,如用python编写测试用例脚本或者开发测试框架以及UI自动化操作方法是一样的,基本是通用.因两者都是基于 ...
- JAVA 解析TXT文本
package file; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; im ...
- python中round(四舍五入)的坑
python中的round函数不能直接拿来四舍五入,一种替代方式是使用Decimal.quantize()函数. 具体内容待补. >>> round(2.675, 2) 2.67 可 ...
- C++有super关键字么?
很多人在学习Java之后,看到Java里面有super关键字,用来表示父类,那么C++里面有super关键字么? 答案是否定的.这也很容易理解,C++由于支持多继承,所以假设存在super关键字,那么 ...