#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 10000*5 + 10;
/*
HDU 1076
关键: 计算的年份未规定上限, 不能用数组, 直接计算出来即可
*/
int main(){
int T;
int year[MAXN];
scanf("%d", &T);
for(int i=0; i<T; i++){
int N,Y;
scanf("%d %d", &N, &Y);
if( ( N%4==0 && N%100!=0 )||(N%400==0) ){
Y--;
}else{
while( !( N%4==0 && N%100!=0 ) && !(N%400==0) ){
N--;
}
}
while( Y ){
N++;
if( ( N%4==0 && N%100!=0 )||(N%400==0) ){
Y--;
}
}
cout << N << endl;
}
return 0;
}
HDU 1076(第n个闰年)
最新推荐文章于 2022-03-12 23:26:09 发布