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. 开发者必备,超实用的PHP代码片段(转)

    此前,研发频道曾发布<直接拿来用,10个PHP代码片段>,得到了网友们的一致好评.本文,笔者将继续分享九个超级有用的PHP代码片段.当你在开发网站.应用或者博客时,利用这些代码能为你节省大 ...

  2. XtraBackup原理4

    MySQL · 答疑解惑 · 物理备份死锁分析 背景 本文对 5.6 主备场景下,在备库做物理备份遇到死锁的case进行分析,希望对大家有所帮助. 这里用的的物理备份工具是 Percona-XtraB ...

  3. cocos2dx jsoncpp

    jsoncpp下载 http://sourceforge.net/projects/jsoncpp/ 下载解压后用到的是include\json下面的头文件跟src\lib_json下的文件. 导入头 ...

  4. AngularJS - 插件,module注入

    Index.html <body> <div ng-app="myApp"> <div ng-controller="firstContro ...

  5. android Button 切换背景,实现动态按钮和按钮颜色渐变

        android Button 切换背景,实现动态按钮和按钮颜色渐变 一.添加android 背景筛选器selector实现按钮背景改变     1.右键单击项目->new->Oth ...

  6. css笔记10:多个id选择器/类选择器包含相同部分问题的探讨

    有些时候,我们可以将多个class选择器或者id选择器,html选择器的共同部分提取出来,写在一起,这样的好处是是可以简化css文件 1.首先我们先看一段代码.css,如下: @charset &qu ...

  7. C#编程实现DNS Client和Server(转)

    我们大多数人使用DNS主要是用于域名解析,近期有个特殊的需求:通过DNS协议传递特殊数据.翻遍互联网,最终找到了一个强大的C# DNS工具库  ARSoft.Tools.Net library ,感谢 ...

  8. C#中登录验证FormsAuthentication

    1:前台编写一个登录界面,这里为了简化,只有用户名和密码 代码如下: <form method="post" action="/User/CheckLogin&qu ...

  9. Activiti流程 关于自定义sql查询

    由于才接触Activiti不久,对于表结构也不熟悉,甚至可以说连那些表对应的实体类都搞不清楚,又不能通过Activiti自带的链式查询实现:在这种情况下跟不知道怎么通过sql去实现自己想要的查询.上网 ...

  10. [改善Java代码]不要在构造函数中抛出异常

    Java的异常机制有三种: 一.Error类以及其子类表示的是错误,它是不需要程序员处理也不能处理的异常.比如VirtualMachineError虚拟机错误,ThreadDeath线程僵尸等. 二. ...