HDOJ1076第几个闰年

来源:互联网 发布:opencv-python在线 编辑:程序博客网 时间:2024/04/28 05:01
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<string.h>
const int inf = 0x3f3f3f;
using namespace std;
bool judge(int x)
{
    if((x % 4  == 0 && x % 100 != 0) ||(x % 400 == 0))
      return true;
    return false;
}
int main()
{
    int test,y,n,ans;
    while(scanf("%d",&test) != EOF)
    {
        while(test--)
        {
            ans = 0;
              scanf("%d%d",&y,&n);
              for(int i = y ; ; i++)
              {
                  if(judge(i))
                  {
                      ans++;
                  }
                  if(ans == n)
                  {
                      printf("%d\n",i);
                      break;
                  }
              }
        }


    }
}
原创粉丝点击