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.
         

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int N,n,m;
scanf("%d",&N);
while(N--)
{
scanf("%d%d",&n,&m);
if((n%==&&n%==)||(n%!=&&n%==))
{
m--;
}
else
{
while(n--)
{
if((n%==&&n%==)||(n%!=&&n%==))
break;
}
}
for(int i=n/+;i<=(n+*m)/;i++)
{
if(i%!=)
{
m++;
}
}
printf("%d\n",n+*m);
}
}

CDZSC_2015寒假新人(1)——基础 h的更多相关文章

  1. CDZSC_2015寒假新人(2)——数学 H

    H - H Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  2. CDZSC_2015寒假新人(1)——基础 e

    Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...

  3. CDZSC_2015寒假新人(1)——基础 i

    Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...

  4. CDZSC_2015寒假新人(1)——基础 g

    Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...

  5. CDZSC_2015寒假新人(1)——基础 f

    Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u i ...

  6. CDZSC_2015寒假新人(1)——基础 d

    Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It i ...

  7. CDZSC_2015寒假新人(1)——基础 c

    Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the wareho ...

  8. CDZSC_2015寒假新人(1)——基础 b

    Description The highest building in our city has only one elevator. A request list is made up with N ...

  9. CDZSC_2015寒假新人(1)——基础 a

    Description Contest time again! How excited it is to see balloons floating around. But to tell you a ...

随机推荐

  1. c++11-bind的用法

    bind函数 在c++11之前,要绑定某个函数.函数对象或者成员函数的不同参数值需要用到不同的转换器,如bind1st.bind2nd.fun_ptr.mem_fun和mem_fun_ref等.在c+ ...

  2. push方法的页面间跳转--

    一,自定义动画写push方法-- 添加coreGraphics.framework框架 在CATransitionAnimation.h文件里面引入-- #import <QuartzCore/ ...

  3. mysql索引之组合索引

    多列索引又称组合索引,在mysql的查询操作中,我们经常会遇到多个搜索条件,如:$sql = "select * from article where content='ma4' and t ...

  4. php,apache伪静态(1转)

    1.检测Apache是否支持mod_rewrite通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,其中列出了所有apache2handler ...

  5. 设置ubuntu Android sdk环境变量

    cd /etc/ sudo gedit profile 在后面把tools和platform-tools的路径追加进去即可 PATH=$PATH:/home/android_sdk/tools 然后再 ...

  6. 基于ViewPager的一些酷炫切换效果

    1.ViewPager可以用于实现类似banner的功能,我曾经在“时间超市”项目中使用过.但如何在此基础上实现一些切换的酷炫效果呢?今天细细品读了鸿洋大神的相关博文,终于学会了如何自定义切换效果. ...

  7. css3绘制几何图形

    用css3绘制你需要的几何图形 1.圆形 示例: 思路:给任何正方形元素设置一个足够大的 border-radius ,就可以把它变成一个圆形.代码如下: html: <div class=&q ...

  8. 如何在异步请求时设置RequestHeader

    一.为何要用到setRequestHeader 通常在HTTP协议里,客户端像服务器取得某个网页的时候,必须发送一个HTTP协议的头文件,告诉服务器客户端要下载什么信息以及相关的参数.而 XMLHTT ...

  9. linux会话命令screen详解

    Screen会话命令 我其实是把文件下载到 /home/zhang/temp/ 里面,当我N久以后再联上服务器,想看看文件下载情况怎样,那又要 cd 老半天,这时候 screen 就是好帮手了. 顾名 ...

  10. android的原理--为什么我们不需要手动关闭程序

    内容搜集自网络,有所删改       不用在意剩余内存的大小,其实很多人都是把使用其他系统的习惯带过来来了.android大多应用没有退出的设计其实是有道理的,这和系统对进程的调度机制有关系.如果你知 ...