计算最近的日期星期相同的的年份。
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cctype>
#include <fstream>
#define INF 0x3f3f3f3f
#define TEST cout<<"stop here"<<endl
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int check(int y){
return ((y%4==0)&&(y%100!=0))||(y%400==0);
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int T;
cin>>T;
while(T--){
char s;
int y,m,d;
int cnt = 0;
cin>>y>>s>>m>>s>>d;
while(true){
if(m==2&&d==29){
cnt = (cnt + 4*365 + check(y))%7;
y += 4;
if(check(y) && !cnt){
break;
}
}
else{
if(m<3)
cnt = (cnt + 365 + check(y))%7;
else
cnt = (cnt + 365 + check(y+1))%7;
y++;
if(!cnt)
break;
}
}
cout<< y <<endl;
}
return 0;
}