博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Educational Codeforces Round 13 B. The Same Calendar 水题
阅读量:4634 次
发布时间:2019-06-09

本文共 1245 字,大约阅读时间需要 4 分钟。

B. The Same Calendar

题目连接:

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 ().

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
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<
<

转载于:https://www.cnblogs.com/qscqesze/p/5582686.html

你可能感兴趣的文章
smartupload 上传文件时 把页面编码改成gbk 解决乱码
查看>>
EPS是什么格式
查看>>
input禁止显示历史输入记录
查看>>
Python的数据库操作(Sqlalchemy)
查看>>
2.抽取代码(BaseActivity)
查看>>
My simplified pickit2 clone
查看>>
Redis 入门知识
查看>>
夏天过去了, 姥爷推荐几套来自smashingmagzine的超棒秋天主题壁纸
查看>>
转--Android如何在java代码中设置margin
查看>>
反射的所有api
查看>>
Js 判断网页窗口是否滚动到底部
查看>>
上传文件
查看>>
css 定位及遮罩层小技巧
查看>>
用java向mysql数据库中插入数据为空
查看>>
项目中非常有用并且常见的ES6语法
查看>>
dateTimePicker编辑状态下,取值不正确的问题
查看>>
mac 端口转发方案
查看>>
[2017.02.23] Java8 函数式编程
查看>>
loadrunner支持https协议的操作方法-经验总结
查看>>
Knowledge Point 20180305 数据在计算机中的表示
查看>>