HD1046An Easy Task
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.)
水题,注意开始年如果也是瑞年的话,也要算一个:
#include<iostream>
using namespace std;
int main(){
int n,a,b,count;
cin>>n;
while(n--){
count=0;
cin>>a>>b;
while(count!=b)
{
a=a+0;
if((a%4==0 && a%100!=0)||a%400==0)
{count ++;}
a++;
}
cout<<a-1<<endl;
}
return 0;
}
HD1046An 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 ...
- An Easy Task
An Easy Task Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- 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 ...
- 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 ...
随机推荐
- Python3 学习第六弹: 迭代器与生成器
1> 迭代器 迭代的意思类似递归一般,不断地对一个对象做重复的操作.来看个例子: class Fibs: def __init__(self): self.last = self.now = 1 ...
- 读取Properties文件工具类
import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java ...
- POJ 1988 Cube Stacking
题意:有编号为1~N的N个小木块,有两种操作 M x y 将木块x所在的堆放到木块y所在的堆的上面 C x 询问木块x下面有多少块木块 代码巧妙就巧妙在GetParent函数中在进行路径压缩的同时,也 ...
- C语言之字节对齐
在C语言编程中,有时为了达到减少运行的时间的目的,需要浪费一些空间:而有时为了节省空间,使它的运行时间增长.而字节对齐则是为了访问效率,用空间换取时间. 要掌握字节对齐,首先得明确一下四个概念: 1. ...
- 正则表达式 java版
众所周知,在程序开发中,难免会遇到需要匹配.查找.替换.判断字符串的情况发生,而这些情况有时又比较复杂,如果用纯编码方式解决,往往会浪费程序员的时间及精力.因此,学习及使用正则表达式,便成了解决这一矛 ...
- ORA-00257错误
Archiver error,connect internal only,until freed 表示归档日志目录已满,用户不能再连接数据库,现有用户可继续查询数据库,但是不能执行DML语句 插删 ...
- errno 与 perror()/strerror()函数
errno是个全局的int型变量,当调用一个系统函数时不管成功不成功都有可能改变errno的值.但只有不成功时errno的值才是有意义的.如果要真的想用errno进行多次打印,刚可以先将其缓存一下.下 ...
- php生成 Arduino 12864 汉字内码
$ch = "你"; $ch = iconv("UTF-8","GB2312",$ch); $xx= sprintf("%X&qu ...
- vsftpd2.3.2安装、配置详解
一.vsftpd 简介 Vsftpd是一个基于GPL发布的类UNIX系统的ftp服务器软件.其全称是Very Secure FTP Deamon,在安全性.速度和稳定性都有着不俗的表现.在安全 ...
- ubuntu 安装AMP环境的笔记 Prefork方式与fast-cgi方法
具体步骤如下: 系统:ubuntu 8.04 的发行版本 AMP with Prefork(mod-php5) 一.安装APACHE2 # sudo apt-get install ...