学会判断闰年就OK。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
int T,a,b,i;
while(scanf("%d",&T)==1)
{
while(T--)
{
scanf("%d%d",&a,&b);
for(i=a;i<=a+100000;i++)
{
if((i%4==0&&i%100!=0)||i%400==0)
b--;
if(b==0)
{
printf("%d\n",i);
break;
}
}
}
}
return 0;
}