An Easy Task
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
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
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
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.
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的更多相关文章
- 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 ...
- HDU-------An Easy Task
An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- ZOJ 2969 Easy Task
E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...
- An Easy Task(简箪题)
B. An Easy Task Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO f ...
- HDU-1076-An Easy Task(Debian下水题測试.....)
An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- Codeforces 263A. Appleman and Easy Task
A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input ...
- 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 ...
- HD1046An Easy Task
Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birt ...
- 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 ...
随机推荐
- .NET 4.0中的泛型协变和反变
转自:http://www.cnblogs.com/Ninputer/archive/2008/11/22/generic_covariant.html 随Visual Studio 2010 CTP ...
- thinkphp中的分表方法
public function getPartitionTableName($data=array()) { // 对数据表进行分区 if(isset($data[$this->partitio ...
- 《Linux内核设计与实现》读书笔记
http://www.cnblogs.com/wang_yb/tag/linux-kernel/
- 随机森林实现 MATLAB
matlab 中随机森林工具箱的下载地址: http://code.google.com/p/randomforest-matlab/downloads/detail?name=Windows-Pre ...
- 强烈推荐240多个jQuery插件提供下载
jQuery 是继 prototype 之后又一个优秀的 Javascript 框架.其宗旨是—写更少的代码,做更多的事情.它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不及 的 ...
- Team Queue
Team Queue Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 2471 Accepted: 926 Descrip ...
- Android(java)学习笔记90:泛型类的概述和使用
用法一: 下面我们首先定义泛型类: package cn.itcast_04; /* * 泛型类:把泛型定义在类上 */ public class ObjectTool<T> { //这里 ...
- Linux 修改swap虚拟内存大小
swap是内存的交换区:换句话说,如果内存不够用了,那么系统会在硬盘上存储一些内存中不常用的数据,之后将这部分数据在存储中析构掉:这样内存就又有剩余空间可以运行东东啦,这个过程也就是所谓的 ...
- javaweb学习总结十五(web开发的相关概念以及常用服务器介绍)
一:java web开发的相关概念 1:web分为静态web和动态web 2:模拟web服务器 web页面如果想让外部网络访问,必须通过网络程序读取资源,流程: a:用户通过浏览器访问网络程序 b:网 ...
- LeetCode 80
Remove Duplicates from Sorted Array II Follow up for "Remove Duplicates": What if duplicat ...