CDZSC_2015寒假新人(1)——基础 h
Description
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
Each test case contains two positive integers Y and N(1<=N<=10000).
Output
Sample Input
2005 25
1855 12
2004 10000
Sample Output
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的更多相关文章
- CDZSC_2015寒假新人(2)——数学 H
H - H Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(1)——基础 e
Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...
- CDZSC_2015寒假新人(1)——基础 i
Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...
- CDZSC_2015寒假新人(1)——基础 g
Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...
- 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 ...
- 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 ...
- CDZSC_2015寒假新人(1)——基础 c
Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the wareho ...
- CDZSC_2015寒假新人(1)——基础 b
Description The highest building in our city has only one elevator. A request list is made up with N ...
- CDZSC_2015寒假新人(1)——基础 a
Description Contest time again! How excited it is to see balloons floating around. But to tell you a ...
随机推荐
- hadoop之MapReduce WordCount分析
MapReduce的设计思想 主要的思想是分而治之(divide and conquer),分治算法. 将一个大的问题切分成很多小的问题,然后在集群中的各个节点上执行,这既是Map过程.在Map过程结 ...
- OpenSuse13.2硬盘安装
直接参考文章:OpenSuse硬盘安装 补充: Win7引导Grub4dos时,本人尝试根据xp引导方式中使用boot.ini来引导,引导成功,不需要bcdedit命令,简化了引导步骤.
- Broadcom网卡linux系统下无法连接到网络问题(某种情况- -||)的解决办法
国际惯例,先闲扯: 其实我是个电脑白痴,至于为什么一个电脑白痴会来做开发呢?原因非常匪夷所思且简单--“因为做开发看起来很酷!”,那为什么要一把年纪了才来做开发呢?原因更简单,“当我回过神,就发现我已 ...
- javascript 过滤空格
1: 过滤首尾空格trim.2:过滤左边空格ltrim 3:过滤右边空格 用正则方法写成三个函数. <script type="text/javascript"> ...
- pyopenssl
https://pyopenssl.readthedocs.org/en/stable/ pyopenssl是一个封装了openssl的python模块. 使用它可以方便地进行一些加解密操作. 1.产 ...
- Project Euler #80: Square root digital expansion
from decimal import getcontext, Decimal def main(): n = int(raw_input()) p = int(raw_input()) getcon ...
- Python 购物车---之商家部分
知识点:文件写入操作, 函数, 函数递归 #!C:\Program Files\Python35/bin # -*- conding:utf-8 -*- # author: Frank # 定义商品列 ...
- js 浮点数加减问题
/** ** 加法函数,用来得到精确的加法结果 ** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显.这个函数返回较为精确的加法结果. ** 调用:accAd ...
- LeetCode_N-Queens
The n-queens puzzle is the problem of placing n queens on an n�n chessboard such that no two queens ...
- 考查嵌入式C开发人员的最好的16道题
约定: 1) 下面的测试题中,认为所有必须的头文件都已经正确的包含了 2)数据类型 char 一个字节 1 byte int 两个字节 2 byte ( ...