很简单的算法基础题...闰年判断以及计算
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int main() 5 { 6 //freopen("input.txt","r",stdin); 7 int year,n; 8 int count; 9 int T; 10 int i; 11 cin>>T; 12 while(T--) 13 { 14 while(cin>>year>>n) 15 { 16 count = 0; 17 for(i = year; ; i++) 18 { 19 if((i % 4 ==0 && i % 100 != 0) || i %400 ==0) 20 { 21 count = 1; 22 break; 23 } 24 } 25 while(count < n) 26 { 27 i += 4; 28 if((i % 4 ==0 && i % 100 != 0) || i %400 ==0) 29 count++; 30 } 31 cout<<i<<endl; 32 } 33 } 34 35 36 return 0; 37 }