CDZSC_2015寒假新人(1)——基础 H

Description

Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him?       
Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap year from year Y.       
Note: if year Y is a leap year, then the 1st leap year is year Y.

Input

The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.        Each test case contains two positive integers Y and N(1<=N<=10000).

Output

For each test case, you should output the Nth leap year from year Y.

Sample Input

3

2005 25

1855 12

2004 10000

Sample Output

2108

1904

43236

Hint

We call year Y a leap year only if (Y%4==0 && Y%100!=0) or Y%400==0.

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
#ifdef CDZSC_OFFLINE
    freopen("in.txt","r",stdin);
#endif
    int year,t,n,sum;
    scanf("%d",&t);
    while(t--)
    {
        sum=0;
        scanf("%d%d",&year,&n);
        while(sum<n)
        {
            if((year%4==0&&year%100!=0)||(year%400==0))
            {
                sum++;
            }
            year++;
        }
        printf("%d\n",year-1);
    }
    return 0;
}

时间: 2024-11-05 23:30:34

CDZSC_2015寒假新人(1)——基础 H的相关文章

CDZSC_2015寒假新人(1)——基础 I

Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course. There are 5 problems i

CDZSC_2015寒假新人(1)——基础 E

Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that

CDZSC_2015寒假新人(2)——数学 - H

Description Sky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶然的机会,他发现了一个有趣的四位数2992,这个数,它的十进制数表示,其四位数字之和为2+9+9+2=22,它的十六进制数BB0,其四位数字之和也为22,同时它的十二进制数表示1894,其四位数字之和也为22,啊哈,真是巧啊.Sky非常喜欢这种四位数,由于他的发现,所以这里我们命名其为Sky数.但是要判断这样的数还是有点麻烦啊,那么现在请你帮忙来判断任何一个十进制的四位数,是不是Sky数吧. Input 输入含有一些

CDZSC_2015寒假新人(1)——基础 B

Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor

CDZSC_2015寒假新人(4)——搜索 H

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Hiking in the mountains is seldom an easy task for most people, as it is extremely easy to get lost during the trip. Recently Green has decided to go on a hiking

CDZSC_2015寒假新人(1)——基础 D

Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.        Give you some integers, your task is to sort these number

CDZSC_2015寒假新人(1)——基础 G

Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the input is a s

CDZSC_2015寒假新人(1)——基础 F

Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting

CDZSC_2015寒假新人(1)——基础 C

Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.        The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds