问题4434--The Same Calendar

4434: The Same Calendar

时间限制: 1 Sec  内存限制: 512 MB
提交: 0  解决: 0
[提交] [状态] [讨论版] [命题人:]

题目描述

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

输入

The only line contains integer y (1000≤y<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

(2)
2000

(3)
50501

样例输出

(1)
2044

(2)
2028

(3)
50507

来源/分类

 

[提交] [状态]