303505: CF678B. The Same Calendar

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

The Same Calendar

题意翻译

给你一个年份n,给出一个大于n的年份,有如下两个要求 ###### 1.天数与n相同 ###### 2.该年的第一天的星期与n年相同 闰年有366天。整除4且不整除100的是闰年,整除400的也是闰年

题目描述

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](https://en.wikipedia.org/wiki/Leap_year)).

输入输出格式

输入格式


The only line contains integer $ y $ ( $ 1000<=y&lt;100'000 $ ) — the year of the calendar.

输出格式


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.

输入输出样例

输入样例 #1

2016

输出样例 #1

2044

输入样例 #2

2000

输出样例 #2

2028

输入样例 #3

50501

输出样例 #3

50507

说明

Today is Monday, the $ 13 $ th of June, $ 2016 $ .

Input

题意翻译

给你一个年份n,给出一个大于n的年份,有如下两个要求 ###### 1.天数与n相同 ###### 2.该年的第一天的星期与n年相同 闰年有366天。整除4且不整除100的是闰年,整除400的也是闰年

加入题单

上一题 下一题 算法标签: