Run ID:56097
提交时间:2023-08-07 18:16:07
#include <iostream> using namespace std; int a[1000001],b[1000001],n,firstyear; int main(){ cin>>n; for(int i = 1;i <=n;i++) { cin >> a[i]>>b[i]; } for(int i = 1;i <=n;i++){ if(a[i]%4==0) { firstyear=a[i]; } else { firstyear=(4-a[i]%4)+a[i]; } if(firstyear%100==0&&firstyear%400!=0) { firstyear+=4; } for(int j = 1;j <b[i];j++) { firstyear+=4; if(firstyear%100==0&&firstyear%400!=0) { j--; } } cout << firstyear<< endl; } }