An Easy Task

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 1   Accepted Submission(s) : 1

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem 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.

题意:
给出起始年份Y,让你求第N个闰年的具体年份。
注意:We call year Y a leap year only if (Y%4==0 && Y%100!=0) or Y%400==0.
        并不是每4年,一闰年,若成立即:Y%4==0 即可。但要满足这个(Y%4==0 && Y%100!=0)。
代码:
#include<stdio.h>
int main(){
    int T,n,y;
    int i,count;
    while(scanf("%d",&T)!=EOF){
    while(T--){
        count=0;
        scanf("%d%d",&y,&n);
        for(i=y;count<n;i++)/* 闰年不是隔四年一循环*/            
            if((i%4==0&&i%100!=0)||(i%400==0))
                count++;/*是闰年就++,等到到了第nth时候就停止,i-1就是要求的年份*/
        printf("%d\n",i-1);
    }
    }
}

An Easy Task的更多相关文章

  1. CodeForces462 A. Appleman and Easy Task

    A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. HDU-------An Easy Task

    An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  3. ZOJ 2969 Easy Task

    E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...

  4. An Easy Task(简箪题)

    B. An Easy Task Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO f ...

  5. HDU-1076-An Easy Task(Debian下水题測试.....)

    An Easy Task Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot ...

  6. Codeforces 263A. Appleman and Easy Task

    A. Appleman and Easy Task time limit per test  1 second memory limit per test  256 megabytes input  ...

  7. Codeforces Round #263 (Div. 2) A. Appleman and Easy Task【地图型搜索/判断一个点四周‘o’的个数的奇偶】

    A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...

  8. HD1046An Easy Task

    Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birt ...

  9. HDOJ 1076 An Easy Task(闰年计算)

    Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birt ...

随机推荐

  1. 使用C#开发纽曼USB来电小秘书客户端小结

    在前面用C#开发完CRM的来电弹屏之后,有些客户有了新的要求,他们希望不但能够实现来电弹屏,更希望能够将呼入呼出的电话录音并上传到CRM服务器上,方便日后跟踪记录.于是便有了来电小秘书客户端的开发.  ...

  2. makefile中的patsubst

    函数名称:加前缀函数—addprefix. 函数功能:为“NAMES…”中的每个文件名称加入前缀“PREFIX”.參数“NAMES…”是空格切割的文件名称序列,将“SUFFIX”加入到此序列的每个文件 ...

  3. Swift3.0相对于2.3语法的一些变化

    前言 : Swift3.0的Swift的第3个主要版本,目标是安全,快速和有表现力,也是第一个有开源社区参与开发的Swift版本.由于语法和API改动比较多,Xcode 8.0 Beta提供了migr ...

  4. Asp.Net+Extjs实现登录

    通过对Ext的学习,发现学习分三部曲:1.看官网的Demo,宏观了解Ext能做什么:2.看相关书籍,做理论指导:3.实现官网的Demo,体会Ext的真谛. 在完毕了第一.二部后,如今我们须要做的是实现 ...

  5. 清除XCode缓存和生成文件

    1.Command-Option-Shift-K to clean out the build folder XCode4.2    finder中找到   /Users/apple/Library/ ...

  6. C加密解密

    /********************************************************* * des.h * 用户使用des算法头文件 * **************** ...

  7. 进程控制之system函数

    ISO C定义了system函数,但是其操作对系统的依赖性很强.POSIX.1包括了system接口,它扩展了ISO C定义,以描述system在POSIX.1环境中的运行行为. #include & ...

  8. QTextEdit 总结

    关于Qt的富文本处理, 可以参考文档:Rich Text Processing 该文档有人翻译了一下(本来我想翻译- -!), 参考Rich Text Processing富文本处理 QTextEdi ...

  9. iOS H5容器的一些探究(一):UIWebView和WKWebView的比较和选择

    一.Native开发中为什么需要H5容器 Native开发原生应用是手机操作系统厂商(目前主要是苹果的iOS和google的Android)对外界提供的标准化的开发模式,他们对于native开发提供了 ...

  10. Ios插件开发

    Ios插件开发 http://www.exmobi.cn/course/course_26.html Android插件开发 http://www.exmobi.cn/course/course_25 ...