http://codeforces.com/problemset/problem/678/B
给定一个年份,求下一个与给定年份完全相同的年份。
完全相同指该年的第一天是周几与当前年是周几完全一样,而且必须是闰年和闰年或者平年和平年。
#include <bits/stdc++.h>
using namespace std;
int y,Y;
int d=0;
bool is(int y){
if ((y%4==0&&y%100!=0)||y%400==0) return true;
return false;
}
int main(){
cin >> y;
Y=y;
while (1){
if (is(y)) d+=2; //366%7==2
else d+=1; //365%7==1
d%=7;
y++;
if (d==0&&is(Y)==is(y)){
cout << y << endl;
exit(0);
}
}
}