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

Educational Codeforces Round 13 B的更多相关文章

  1. Educational Codeforces Round 13 D:Iterated Linear Function(数论)

    http://codeforces.com/contest/678/problem/D D. Iterated Linear Function Consider a linear function f ...

  2. Educational Codeforces Round 13 D. Iterated Linear Function (矩阵快速幂)

    题目链接:http://codeforces.com/problemset/problem/678/D 简单的矩阵快速幂模版题 矩阵是这样的: #include <bits/stdc++.h&g ...

  3. Educational Codeforces Round 13 E. Another Sith Tournament 状压dp

    E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...

  4. Educational Codeforces Round 13 D. Iterated Linear Function 水题

    D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...

  5. Educational Codeforces Round 13 C. Joty and Chocolate 水题

    C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...

  6. Educational Codeforces Round 13 B. The Same Calendar 水题

    B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...

  7. Educational Codeforces Round 13 A. Johny Likes Numbers 水题

    A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...

  8. Educational Codeforces Round 13 A、B、C、D

    A. Johny Likes Numbers time limit per test 0.5 seconds memory limit per test 256 megabytes input sta ...

  9. Educational Codeforces Round 13

    http://codeforces.com/contest/678 A:水题 #include<bits/stdc++.h> #define fi first #define se sec ...

  10. Educational Codeforces Round 13 A

    Description Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x gr ...

随机推荐

  1. 第二部分 实习操作课程 第一节 ArcGIS Online的基本功能

  2. css知多少(3)——样式来源与层叠规则(转)

    css知多少(3)——样式来源与层叠规则   上一节<css知多少(2)——学习css的思路>有几个人留言表示思路很好.继续期待,而且收到了9个赞,我还是比较欣慰的.没看过的朋友建议先去看 ...

  3. 百度Apollo解析——1.总介绍

    1. 概括 Apollo源码主要是c++实现的,也有少量python,主要程序在apollo/modules目录中,共18个包,功能包17个: 其中每个模块的作用如下: apollo/modules/ ...

  4. cocos打包到ios与android上音频推荐

    首先贴一张官方对于ios与android上音频格式的推荐: 这里只给出了推荐格式,一般我们在实际运用中会使用如下方式: 一.IOS与安卓各一套:音乐:都使用MP3    音效:ios用caf Andr ...

  5. ZF 语法

    Zend Framework Command Line Console Tool v1.11.11 Details for action "" and provider " ...

  6. SpringBoot04 日志框架之Logback

    1 日志框架选择 日志门面:SLF4J 日志实现:Logback 2 实现控制台的日志打印输出01 2.1 在需要实现日志信息打印的类中实例化Logger对象 坑01:springBoot项目默认使用 ...

  7. SpringMVC_01 SpringMVC五大组件、SpringMVC编程步骤(不使用注解进行配置)、SpringMVC编程步骤(利用注解进行配置)、参数获取、响应数据

    1 什么是SpringMVC 是一个mvc框架,用来简化基于mvc架构的web应用程序的 开发. 2 SpringMVC五大组件 DispatcherServlet (前端控制器) HanlderMa ...

  8. 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-002插入排序法(Insertion sort)

    一.介绍 1.时间和空间复杂度 运行过程 2.特点: (1)对于已排序或接近排好的数据,速度很快 (2)对于部分排好序的输入,速度快 二.代码 package algorithms.elementar ...

  9. 718C Sasha and Array

    传送门 题目 Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be ...

  10. Entity Framework Tutorial Basics(37):Lazy Loading

    Lazy Loading: One of the important functions of Entity Framework is lazy loading. Lazy loading means ...