暑假第一周 A
来源:互联网 发布:c语言中的指针是什么 编辑:程序博客网 时间:2024/06/05 06:03
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 ywhen 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).
The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.
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.
2016
2044
2000
2028
50501
50507
Today is Monday, the 13th of June, 2016
//A
#include <iostream>using namespace std;
int Leap(int y){
if(y%400==0||(y%4==0&&y%100!=0)){
return 1;
}
return 0;
}
int main()
{
int y;
while(cin>>y){
int j=0;
int flag=Leap(y);
for(int i=y; ;i++){
if(Leap(i)){
j+=2;
}else j++;
if(j%7==0&&Leap(i+1)==flag){
cout<<i+1<<endl;
break;
}
}
}
return 0;
}
- 暑假第一周 A
- 暑假的第一周
- 暑假第一周 I
- 暑假第一周 L
- 暑假第一周 R
- 暑假第一周 E
- 暑假第一周 T
- 暑假第一周 B
- 暑假第一周 C . CodeForces 660A Co-prime Array
- 暑假集训第一周总结
- 暑假学习任务第一周
- 暑假留校--第一周总结
- 暑假第一周学习总结
- 暑假留校第一周总结
- 2013年暑假实习第一周总结
- 2015暑假集训第一周题目总结
- WUST暑假集训第一周简单小结
- 暑假第一周 F (水题)
- IntelliJ Idea 常用快捷键列表
- python类创建过程
- Number 对象
- 关于cuda和shader的共同点的一些思考
- jsp之简单的验证码生成
- 暑假第一周 A
- Java核心技术
- java中的选择结构和循环结构
- ? addActionListener()调用actionPerformed()
- jsp中的九大隐含对象和EL中的隐含对象
- JS history(一)返回上一页
- 在Android Studio中有六种依赖
- 全排列问题算法实现--递归
- 暑假第一周 R