Educational Codeforces Round 13 B. The Same Calendar 水题
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 水题的更多相关文章
- Educational Codeforces Round 13 D. Iterated Linear Function 水题
D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...
- Educational Codeforces Round 13 C. Joty and Chocolate 水题
C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...
- Educational Codeforces Round 13 A. Johny Likes Numbers 水题
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...
- Educational Codeforces Round 14 A. Fashion in Berland 水题
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...
- Educational Codeforces Round 4 A. The Text Splitting 水题
A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...
- 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 ...
- 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 ...
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
随机推荐
- Memcached服务器UDP反射放大攻击
1.前言 2月28日,Memcache服务器被曝出存在UDP反射放大攻击漏洞.攻击者可利用这个漏洞来发起大规模的DDoS攻击,从而影响网络正常运行.漏洞的形成原因为Memcache 服务器UDP 协议 ...
- 为什么使用do{}while(0)来进行宏定义
最近发现很多代码在进行宏定义的时候使用喜欢使用 #define MACRO_NAME(para) do{macro content}while(0) 的格式,总结了以下几个原因: 1,空的宏定义避 ...
- Python缓存技术,装x新高度。
一段非常简单代码 普通调用方式 def console1(a, b): print("进入函数") return (a, b) print(console1(3, 'a')) pr ...
- asp.net 获取音视频时长 的方法
http://www.evernote.com/l/AHPMEDnEd65A7ot_DbEP4C47QsPDYLhYdYg/ 日志: 1.第一种方法: 调用:shell32.dll ,win7 ...
- Javascript中的Callback方法浅析
什么是callback? 回调函数就是一个通过函数指针调用的函数.如果你把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用为调用它所指向的函数时,我们就说这是回调函数.回调函数不是由该函数 ...
- 调研助力4S店,解码困境谜团
关键词————4S店.汽车.销售.精准营销.闭环.用户满意度.精细化管理 一.背景 4S店是“四位一体”的汽车销售专卖店,包括了整车销售.零配件供应.售后服务.信息反馈四项功能. 信息化管理 精细化管 ...
- Registry私有仓库搭建及认证
本节内容: Registry相关概念 Registry V1和V2 安装Docker 搭建本地registry v2 搭建外部可访问的Registry 添加认证 更高级的认证 registry web ...
- #JS Ajax的error函数
使用jquery的ajax方法向服务器发送请求的时候,常常需要使用到error函数进行错误信息的处理, 一般error函数返回的参数有三个: function(jqXHR jqXHR, String ...
- JSP的学习二(指令与标签)
一:page指令 1.JSP的指令 放在<%@ 指令 属性=“值”%> 主要有page,include,tablib. 2.page指令 用于定义JSP页面的各种属性,作用于是JSP的整个 ...
- MySQL 大数据量使用limit分页,随着页码的增大,查询效率越低下。
数据表结构 CREATE TABLE `ad_keyword` ( `id` int(11) NOT NULL AUTO_INCREMENT, `plan_goods_id` int(11) DEFA ...