杭电 1076(水题 暴力)
来源:互联网 发布:mmd威风堂堂动作数据 编辑:程序博客网 时间:2024/05/17 23:47
An Easy Task
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14543 Accepted Submission(s): 9295
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.
Author
Ignatius.L
代码如下:
#include<stdio.h>int main(){ int n,y,t,i,j; scanf("%d",&t); while(t--) { scanf("%d%d",&y,&n); for(i=0;i<n;i++) { for(j=y;;j++) { if(j%400==0||j%4==0&&j%100!=0) { y=++j; break; } } } printf("%d\n",y-1); } return 0;}
0 0
- 杭电 1076(水题 暴力)
- 杭电 2566(母函数 暴力)
- 杭电1015 Safecracker 暴力
- 杭电1239————缩小数据范围的暴力搜索(水题)
- 杭电5311-Hidden String(暴力列举)
- 【杭电oj】1276 - 士兵队列训练问题(队列,暴力)
- 暴力ac杭电2020绝对值排序
- 杭电1172 猜数字(暴力)
- 杭电1407--暴力与优化
- 杭电acm 字符串暴力 1004
- The 3n + 1 problem(杭电1032)(暴力求解)
- 杭电1598 find the most comfortable road(并查集暴力求解)
- 杭电ACM 1015 很笨的暴力解法
- HDU--杭电--2303--The Embarrassed Cryptographer--暴力爆菊花
- 杭电 2141 Can you find it?二分法+暴力查找
- 杭电1081 暴力dp 最大子矩阵和
- 杭电 hdu 5616 Jam's balance【思维】【暴力枚举】
- 杭电 2700(水题)
- GPU编程之GLSL(四)——片段着色器
- dojo把字符串转换成json数组
- 【TOJ 3403】Treasure Division 【双向搜索】
- Play Framework Web开发教程(16): 处理HTTP请求和响应
- Web 软件测试 Checklist 应用系列 第 1 部分: 数据输入
- 杭电 1076(水题 暴力)
- void型函数中return语句的作用
- position:absolute 时 margin-bottom 不起作用
- Akka 编程(14): Become/Unbecome
- HDU-#2005 第几天?
- 最大团
- 自由操控声音-相位声码器-变调篇(一)
- Java获取最近一周的时间
- 常见的单端阻抗计算模式(参考网上的部分文章)