B. The Same Calendar

题目连接:

http://www.codeforces.com/contest/678/problem/B

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.

Sample Input

2016

Sample Output

2044

Hint

题意

给你一个年y,让你找到大于y的某一年,使得和y这一年的日期一模一样。

题解:

其实就是经过的天数%7==0

而且那一年的平闰年和这一年是一样的。

代码

#include<bits/stdc++.h>
using namespace std; bool check(int p)
{
if(p%400==0)return 1;
if(p%4==0&&p%100!=0)return 1;
return 0;
}
int main()
{
int y;
scanf("%d",&y);
int ans = y+1;
int p=(365+check(ans))%7;
while(p!=0||check(y)!=check(ans))
p=(p+365+check(++ans))%7;
cout<<ans<<endl;
}

Educational Codeforces Round 13 B. The Same Calendar 水题的更多相关文章

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

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

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

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

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

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

  4. Educational Codeforces Round 14 A. Fashion in Berland 水题

    A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...

  5. Educational Codeforces Round 4 A. The Text Splitting 水题

    A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...

  6. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...

  7. Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题

    A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...

  8. Educational Codeforces Round 12 A. Buses Between Cities 水题

    A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...

  9. Educational Codeforces Round 11 B. Seating On Bus 水题

    B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...

随机推荐

  1. Interger不可变原理

    1.先看代码: package main.java.db.mq; public class TestSwap { public static void main(String[] args) { In ...

  2. asp.net 伪静态实现(UrlRewritingNet)

    UrlRewritingNet.UrlRewriter源码地址 https://github.com/aspnetde/UrlRewritingNet部署步骤: 步骤一: <!--只允许存在一个 ...

  3. 十分钟搞懂快速傅里叶变换(FFT)

    己学习的笔记,欢迎大家指正.

  4. python configparser配置文件解析器

    一.Configparser 此模块提供实现基本配置语言的ConfigParser类,该语言提供类似于Microsoft Windows INI文件中的结构.我们经常会在一些软件安装目录下看到.ini ...

  5. [转]关于MyEclipse下的项目无法使用BASE64Encoder问题的解决办法

    [链接] http://blog.csdn.net/longlonglongchaoshen/article/details/75087616

  6. 本地删除文件,git远程不同步删除

    git add -a 或 git add * 它能stages所有文件,包括之前删除的痕迹 git add . 只能stages新文件和被修改的文件,不会stages已被删除的文件 步骤如下: 1) ...

  7. 在windows中安装两个不同版本的Python

    这段时间买了一本 利用Python进行数据分析的书.书上要我将原来安装的Python的环境去掉,但是我觉得这样做不行,我以前写过的很多东西还在呢.遂在博客中找到了解决方法,记录之. 首先,我们安装了两 ...

  8. gtk+学习笔记(八)

    框架(Frames)可以用于在盒子中封装一个或一组构件,框架本身还可以有一个标签.标签的位置和盒子的风格可以灵活改变. 框架可以用下面的函数创建: GtkWidget *gtk_frame_new( ...

  9. 从exp入手分析漏洞

    分析poc和分析exp有一些不一样,因为exp是人为构造后的东西,它会执行一段自定的shellcode.结果是根本不会触发异常或者异常在离触发点十万八千里的地方.这样分析poc的技巧就用不上了(因为无 ...

  10. OA项目Spring.Net代替抽象工厂(三)

    Servrvice层的代码: <?xml version="1.0" encoding="utf-8" ?> <objects xmlns=& ...