An Easy Task

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 17062    Accepted Submission(s): 10902

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.
 
Author
Ignatius.L
 
Recommend
We have carefully selected several similar problems for you:  1021 1097 

pid=1061" target="_blank">1061 1032 1170






题目的意思非常easy:

就是让你求出从Y開始的年份第N个闰年......甚至不用考虑时间复杂度,强行AC!

主要是Debian下命令行不熟悉,费了不少时间......

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int t,Y,N;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&Y,&N);
while(1)
{
if((Y%4==0&&Y%100!=0)||(Y%400==0))
{
N--;
}
if(N==0)
break;
Y++;
}
printf("%d\n",Y);
}
return 0;
}

最新文章

  1. Linux(四)__javaee开发环境的搭建
  2. linux系统磁盘分区之parted
  3. Unity3d在安卓android的更新(APK覆盖)
  4. SSAS 发布报错处理方法 Login failed for user &#39;NT Service\MSSQLServerOLAPService&#39; 28000
  5. 【QT相关】类头文件解读、QT编辑模式、读取text文本
  6. LR的VG与Control之间的关系,并发的实质
  7. zf-删除重复数据只保留一条(转)
  8. Oracle-SQL-按月统计自助终端交易量
  9. 【憩园】C#并发编程之异步编程(二)
  10. springboot ****使用经验*******
  11. angular.isObject()
  12. Mysql加锁过程详解(1)-基本知识
  13. 异常来自 HRESULT:0x80070057 (E_INVALIDARG)(转)
  14. spark_wordcount
  15. A1070. Mooncake
  16. python - class内置方法 doc/module/del(析构方法)/cal 方法
  17. js判断软键盘是否开启弹出
  18. SpingMVC的&lt;context:component-scan&gt;包扫描踩坑记录
  19. 将keras模型在django中应用时出现的小问题——ValueError: Tensor Tensor(&quot;dense_2/Softmax:0&quot;, shape=(?, 8), dtype=float32) is not an element of this graph.
  20. 01—为什么使用java

热门文章

  1. 数据结构( Pyhon 语言描述 ) — — 第1章:Python编程基础
  2. Jmeter接口测试-简单分析结果数、聚合报告以及图形结果(二)
  3. C# 字符串型转数字型
  4. BZOJ 1829 [Usaco2010 Mar]starc星际争霸 ——半平面交
  5. [BZOJ1582] [Usaco2009 Hol]Holiday Painting 节日画画(线段树)
  6. HashTable的构造函数有哪些
  7. bzoj2144 跳跳棋 二分
  8. IBM内存三技术:Chipkill、MPX、MM
  9. 费用流(bzoj 3130)
  10. Resin Thread Dump