当前位置: 移动技术网 > IT编程>开发语言>C/C++ > hdu 1076 An Easy Task

hdu 1076 An Easy Task

2018年09月12日  | 移动技术网IT编程  | 我要评论

疯狂猜图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;
}


 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网