疯狂猜图ana,聊城人流,启芳堂
time limit: 2000/1000 ms (java/others)memory limit: 65536/32768 k (java/others)
total submission(s): 19908accepted submission(s): 12725
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
y 开始以后的第n个闰年
闰年为能被4整除不能被100整除 或者被400整除
#include
int main()
{
int ncase;
scanf("%d",&ncase);
while(ncase--)
{
int year,n;
scanf("%d %d",&year,&n);
for(int i=year;;i++)
{
if((i%4==0&&i%100)||i%400==0)
n--;
if(n==0)
{
printf("%d\n",i);
break;
}
}
}
return 0;
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
C++ 作用域
作用域:名称在翻译单元(包括文件)的可见范围 局部: 只在定义它的代码块中可用,如自动变量 全局(文件作用域): 从定义位置到文件结尾都可用 注意: 静...
[阅读全文]
-
-
-
-
聚合类型与POD类型
Lippman在《深度探索C++对象模型》的前言中写道: I have heard a number of people over the years ...
[阅读全文]
-
-
-
-
-
网友评论