2023 2023 2024由于考虑到最多400年一次轮回,所以可以考虑暴力,对于输入大于2月29的情况,我们只要考虑下一年是否是闰年就行,小于2月29的情况,我们要考虑当前年是否是闰年,对于是闰年又是2月29号的情况,我们要每次都判断,并且,要在闰年的时候是否是满足的情况。每次年份只能加1.要考虑到每一百年的 情况。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
#define LL __int64
#define siz 1005
#define LL long long
using namespace std;
int n,m,k;
int year,month,day;
void solve(){
if((((year)%4==0&&(year)%100!=0)||(year)%400==0)&&month==2&&day==29){
int t=0;
LL ans = 0;
while(true){
//++t;
++year;
if(((year)%4==0&&(year)%100!=0)||(year)%400==0){
ans += 366;
if(ans%7==0){
printf("%d\n",year);
break;
}
}
else{
ans += 365;
}
//ans+=1461;
// t+=4;
}
return ;
}
LL ans = 0;
for(int i=1;i<=10000;i++){
int ye;
if(month>2){
ye = year +i;
}
else{
ye = year+i-1;
}
//int ye = year + i;
if(((ye)%4==0&&(ye)%100!=0)||(ye)%400==0){
ans += 366;
}
else{
ans += 365;
}
if(ans%7==0){
if(month>=32)
printf("%d\n",ye);
else{
printf("%d\n",ye+1);
}
break;
}
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--){
// int p;
scanf("%d-%d-%d",&year,&month,&day);
solve();
}
return 0;
}