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 ...
随机推荐
- Effective C++(12) 复制对象时要复制每一个成员
问题聚焦: 负责拷贝的两个操作:拷贝构造函数和重载赋值操作符. 一句话总结,确保被拷贝对象的所有成员变量都做一份拷贝. Demo void logCall(const std::string&am ...
- iOS基础 - Quartz 2D绘图的基本步骤
一.使用Quartz 2D绘图的基本步骤 1) 获取上下文context(绘制图形的地方) 2) 设置路径(路径是用来描述形状的) 3) 将路径添加到上下文 4) 设置上下文属性(设置颜色,线宽, ...
- FineUI开发一个b/s结构
手把手教你使用FineUI开发一个b/s结构的取送货管理信息系统(附源码+视频教程(第5节)) 一 本系列随笔概览及产生的背景 近阶段接到一些b/s类型的软件项目,但是团队成员之前大部分没有这方面 ...
- sqlite3结合ios开发
简介: SQLite是遵守ACID的关系数据库管理系统,它包含在一个相对小的C库中.它是D.RichardHipp创建的公有领域项目. 不像常见的客户端/服务器结构范例,SQLite引 ...
- require.js实践
ASP.NET MVC应用require.js实践 这里有更好的阅读体验和及时的更新:http://pchou.info/javascript/asp.net/2013/11/10/527f6ec41 ...
- ResolveUrl in ASP.NET - The Perfect Solution
原文:ResolveUrl in ASP.NET - The Perfect Solution If you are looking for ResolveUrl outside of Page/Co ...
- CSS 选择器的学习
从蛋学习 CSS 选择器 + 做一个 Jumony 桌面工具,真费劲,目前Jumony Tool两大问题无法解决,完美的显示 html 文档和根据结果在文档中定位,有点儿跑题了…… 1. 选择“cla ...
- Windows 安装Mongoliadb
1. 下载 下载地址: http://www.mongodb.org/downloads 我这里用的是:mongodb-win32-x86_64-2008plus-2.4.5.zip 2. 设置目录 ...
- 为什么MD5不能解密
MD5加密原理是散列算法,也称之为hash算法. 具体的算法很多种,我也不是很懂,写得太专业了,我们只能理解一些简单的.简单才能让人记得住. 举例说明,10除以3余数是1,4除以3的余数也是1,反过来 ...
- computer专业术语总结
计算机专业真可谓是博大精深,光语言就有N多种,而且各种算法计数,各个领域,加之新技术的不断出现, 如果想要穷尽 计算机的知识,那绝对是不那个可能的,只能在若干领域才能取得一定的成果,但是多了解一些专业 ...