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. Tornado之抽屉实战(1)--分析与架构

    项目模拟地址:http://dig.chouti.com/ 知识点应用: AJAX  用于偷偷发请求 原生ajax jQuery  ajax($.ajax) iframe伪造 上传文件 传统Form ...

  2. AndroidImageSlider(图片轮播控件)

    1,引入 dependencies { compile "com.android.support:support-v4:+" compile 'com.squareup.picas ...

  3. Java 访问 Kylin 总结

    这次开发功能是OEM统计报表.统计报表的数据由大数据平台部的同事收集,数据的展示由我们部门开发. 大数据那边使用 Kylin 分布式分析引擎(kylin官方文档). Kylin 虽比较偏向大数据相关, ...

  4. 03 MD5加密、Base64处理

    1 什么是MD5 信息摘要算法,可以将字符进行加密,每个加密对象在进行加密后都是等长的 应用场景:将用户密码经过MD5加密后再存储到数据库中,这样即使是超级管理员也没有能力知道用户的具体密码是多少:因 ...

  5. 关于Java继承体系中this的表示关系

    Java的继承体系中,因为有重写的概念,所以说this在子父类之间的调用到底是谁的方法,或者成员属性,的问题是一个值得思考的问题; 先说结论:如果在测试类中调用的是子父类同名的成员属性,这个this. ...

  6. 999F Cards and Joy

    传送门 题目大意 有n个人n*m张牌,每个人分m张牌.每个人有一个自己喜欢的数值,如果他的牌中有x张数值等于这个值则他的高兴度为L[x],求怎样分配牌可以使得所有人的总高兴度最大. 分析 我们发现每一 ...

  7. Luogu 2254 [NOI2005]瑰丽华尔兹

    简单dp,设$f_{i,j,k}$表示第i个时间段,钢琴处在(j,k)位置移动距离的最大值,那么有转移 $f_{i, j, k} = max(f_{i - 1, j, k}) ,  f_{i, j, ...

  8. Luogu 3759 [TJOI2017]不勤劳的图书管理员

    再也不作死写FhqTreap作内层树了,卡的不如暴力呜呜呜…… 题意翻译:给一个序列,每个下标包含两个属性$a$和$v$,求第一个属性与下标形成的所有逆序对的第二个属性和,给出$m$个交换两个下标的操 ...

  9. 面试经常问的一个问题:final、finalize、finally

    http://m.blog.csdn.net/u010980446/article/details/51493658

  10. com.fasterxml.jackson.databind.JavaType.isReferenceType

    <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-map ...