HDU-------An Easy Task
An Easy Task |
| Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
| Total Submission(s): 4088 Accepted Submission(s): 2327 |
|
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 Note: if year Y is a leap year, |
|
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 |
|
Sample Output
2108 Hint
We call year Y a leap year only if (Y%4==0 && Y%100!=0) or Y%400==0. |
|
Author
Ignatius.L
|
easy task并不easy 无奈 不过不着急慢慢来 在错误和失败中学到东西才是重要的
上代码
#include <iostream>
using namespace std;
//int leapJudge(int);
int main(){
int cont,sYear,pYear; cin>>cont;
//while(cont--)//这个cont--还是谜一样的存在 !while(i--)中i是有个初值的,每次循环i会减1,当i的值等于0的时候,循环就会终止! for(int i =;i<cont;i++)
{
int sYear = ;
int pYear = ;
cin>>sYear>>pYear;
int leapcont = ; //!!!!!!重大错误就出现在这句 之前把他放在第一层循环外 也是脑子瓦特掉了
int j;
for(j=sYear;;j++){
if(leapcont==pYear) break;
if((j%==&&j%!=)|j%==)//去掉了判断函数 因为确实是没什么卵用
leapcont++;
}
cout<<j-<<endl;//此处也是有一个错误 应该输出j-1
}
//system("pause");
return ;
}
//int leapJudge(int Y){
// if( (Y%4==0 && Y%100!=0)||Y%400==0)
// return 1;
//} //#include<iostream>
//using namespace std;
//
//int main()
//{
// int cases;//
// int k;
// cin>>cases;
// while(cases--)
// {
// int y,n;
// cin>>y>>n;
// int num=0;
// for(k=y;;k++)
// {
// if(num==n) break;
// //判断是不是闰年
// if(k%4==0 && k%100!=0 || k%400==0)
// num++;
// }
// cout<<k-1<<endl;
// }
// system("pause");
// return 0;
//}
总结:循环之间的逻辑不清晰
HDU-------An 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 ...
- 二分+DP HDU 3433 A Task Process
HDU 3433 A Task Process Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- An Easy Task
An Easy Task Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- hdu 3433 A Task Process 二分+dp
A Task Process Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 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 ...
随机推荐
- strlen与sizeof有什么区别?
其实二者的区别还是很大的,首先strlen计算的长度不包括字符串最后的终止null字节, 而sizeof则计算包括终止null的缓冲区长度.还有一点很容易被忽略,strlen需要一次函数调用, 即它是 ...
- poj 2184(dp变形,进一步加深01背包)
点击打开链接 题意: 给你n个物品,每个物品都有两个属性,s和f,要求选择一些物品,使sum(s)+sum(f)最大,并且sum(s)>=0&&sum(f)>=0, 根据0 ...
- DLL文件的引用
首先我们先要写一个DLL文件: 我先创建一个win32的DLL工程,在工程中添加了Math.h和Math.cpp文件,具体内容如下: Math.h: #pragma once #include &qu ...
- 通过Func 委托理解委托和匿名方法及Lambda 表达式
Func<T, TResult> 委托 封装一个具有一个参数并返回 TResult 参数指定的类型值的方法. 命名空间: System 程序集: mscorlib(在 mscorlib.d ...
- OA小助手
基于 WPF + Modern UI 的 公司OA小助手 开发总结 前言: 距离上一篇博客,整整一个月的时间了.人不能懒下来,必须有个阶段性的总结,算是对我这个阶段的一个反思.人只有在总结的过程中才会 ...
- js闭包和ie内存泄露原理
也议 js闭包和ie内存泄露原理 可以, 但小心使用. 闭包也许是 JS 中最有用的特性了. 有一份比较好的介绍闭包原理的文档. 有一点需要牢记, 闭包保留了一个指向它封闭作用域的指针, 所以, 在给 ...
- MongoDB学习(翻译6)
接上篇.... 字段或属性层次的序列化选项 有许多种让你控制序列化的方式,上一节通过约定方法来控制序列化,你也可以通过代码配置或者成员映射或者使用特性来控制你的序列化,下面说道的序列化的各个方面,我们 ...
- 使用brew安装软件
使用brew安装软件 brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便 brew类似ubuntu系统下的apt- ...
- ubuntu 学习笔记1--安装jdk
ubuntu 版本13.10 安装jdk参考网址http://stackoverflow.com/questions/14788345/how-to-install-jdk-on-ubuntulinu ...
- Fortran使用隐形DO循环和reshape给一维和多维数组赋初值
Fortran可以使用隐形DO循环和reshape给一维和多维数组赋初值. 下面以一维数组和二维数组为例,并给出程序结果: program main implicit none integer::i, ...