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.

Examples
input
2016
output
2044
input
2000
output
2028
input
50501
output
50507
Note

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

这个我使用基姆拉尔森计算公式求相同日期如果星期数相同,就看做日历相同。。这里我是拿1月1,3月1,和12月1比较。都相同就是相同的。。

其实正确解法是计算每年相隔天数。。如果是7的倍数而且平闰相同就是结果。

 #include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<time.h>
#include <stdlib.h>
using namespace std;
int Day_weak(int year,int month,int day)
{
if(month==||month==)
{
month +=;
--year;
}
int week = -;
week=(day+*month+*(month+)/+year+year/-year/+year/)%+;
return week; // 输出-1为错误
}
int main()
{
int a,b,c;
int i;
cin>>a;
for(i=a+;i<=;i++)
{
if(Day_weak(a,,)==Day_weak(i,,)&&Day_weak(a,,)==Day_weak(i,,)&&Day_weak(a,,)==Day_weak(i,,))
{
break;
}
}
cout<<i<<endl;
return ;
}

最新文章

  1. 微信小程序开发日记——高仿知乎日报(下)
  2. Appcan——Box
  3. .htaccess 基础教程(四)Apache RewriteCond 规则参数
  4. 关于 jsp 解析特殊字符的问题
  5. 解决 CentOS网卡eth0启用不了问题
  6. 第12章 在.NET中操作XML
  7. Maven学习总结(三)——使用Maven构建项目
  8. 【POI xlsx】使用POI对xlsx的单元格样式进行设置 / 使用POI对xlsx的字体进行设置
  9. sql查阅每一月的数据
  10. php错误日志级别
  11. 从零开始用 Flask 搭建一个网站(一)
  12. 前端到后台ThinkPHP开发整站(5)
  13. DOM节点的创建
  14. SSRS报表服务随笔(rdl报表服务)-报表参数
  15. Django中使用极验Geetest滑动验证码
  16. cf438E. The Child and Binary Tree(生成函数 多项式开根 多项式求逆)
  17. 【vue】vue +element 搭建项目,点击空白处关闭弹窗
  18. elasticsearch数据输入和输出
  19. 数据类型&amp;分支流程控制(2)
  20. Python2.7-StringIO和cStringIO

热门文章

  1. spring-boot 热加载实现替换Jrebel
  2. 异常 android.content.res.Resources$NotFoundException: String resource ID #0x61
  3. android键盘的Done按钮
  4. Jsonp实现跨域请求Ajax
  5. poj1753-Flip Game 【状态压缩+bfs】
  6. [poj1509]Glass Beads(最小表示法)
  7. java 矩阵转置算法
  8. EZOJ #81
  9. 简单VBS教程.RP
  10. WordCountPro小程序