Hdu 1076 An Easy Task【水】
来源:互联网 发布:如何编写抢购软件 编辑:程序博客网 时间:2024/06/01 19:41
An Easy Task
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19001 Accepted Submission(s): 12148
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.
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).
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
32005 251855 122004 10000
Sample Output
2108190443236HintWe call year Y a leap year only if (Y%4==0 && Y%100!=0) or Y%400==0.
给出开始的年份Y,问第N 个闰年是哪一年
唯一能想到的办法就是循环暴力枚举,想想会超时,然后再上网搜解法,继而发现神奇的与闰年相关的结论,没想到...暴力竟然AC了, 然后瞬间感觉自己想多了........
#include<stdio.h>#include<string.h>bool leap(int x){return x%4==0&&x%100!=0||x%400==0;}int main(){int t;scanf("%d",&t);while(t--){int y,n;scanf("%d%d",&y,&n);while(n){if(leap(y)){--n;}++y;}printf("%d\n",y-1);}return 0;}
0 0
- HDU 1076 An Easy Task (水)
- HDU 1076 An Easy Task(水~)
- Hdu 1076 An Easy Task【水】
- hdu 1076 An Easy Task
- HDU 1076 An Easy Task
- HDU 1076 An Easy Task
- Hdu 1076 - An Easy Task
- HDU 1076 An Easy Task
- hdu 1076 An Easy Task
- hdu 1076 An Easy Task
- HDU 1076 An Easy Task
- hdu-1076-An Easy Task
- hdu 1076 An Easy Task
- HDU 1076An Easy Task
- hdu 1076 An Easy Task
- hdu 1076 An Easy Task
- HDU 1076 An Easy Task
- hdu 1076 An Easy Task
- tcp/ip基础(一)
- 数据流分析的局限性
- jQuery小练习
- ACM路上的一大失误
- QTCreator 生成可执行程序不能运行的问题
- Hdu 1076 An Easy Task【水】
- CSS3:有雪花的导航栏实例
- hdu 1286找新朋友 (欧拉函数筛法)
- leetcode67.AddBinary
- uva 11609 组合数学
- 每天几个Linux命令01_ls命令
- linux同步(二)---等待队列
- jquery与checkbox的checked属性的问题
- poj1061青蛙的约会 (扩展欧几里德)