hdu 1076(日期相关)

View Code
/*
  Name: 日期相关 
  Copyright: 
  Author: Try86
  Date: 15/04/12 23:32
  Description: 
*/
#include <cstdio>
#include <iostream>

using namespace std;

bool isLeap(int year) {
    if (year%400==0 || year%4==0&&year%100!=0) return true;
    return false;
} 

int main() {
    int t;
    scanf ("%d", &t);
    while (t--) {
        int year, n, i;
        scanf ("%d%d", &year, &n);
        int cs = 1;
        for (i=0; cs<=n; ++i) {
            if (isLeap(year+i)) ++cs;
        }
        printf ("%d\n", year+i-1);
    }
    return 0;
}

 

posted on 2012-04-16 07:34  Try86  阅读(238)  评论(0)    收藏  举报