HDU-1076-An Easy Task(Debian下水题測试.....)

An Easy Task

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 17062    Accepted Submission(s): 10902

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.

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
2005 25
1855 12
2004 10000

Sample Output

2108
1904
43236

Hint

We call year Y a leap year only if (Y%4==0 && Y%100!=0) or Y%400==0.


 

Author

Ignatius.L

Recommend

We have carefully selected several similar problems for you:  1021 1097 pid=1061" target="_blank">1061 1032 1170

题目的意思非常easy:

就是让你求出从Y開始的年份第N个闰年......甚至不用考虑时间复杂度,强行AC!

主要是Debian下命令行不熟悉,费了不少时间......

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int t,Y,N;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&Y,&N);
        while(1)
        {
            if((Y%4==0&&Y%100!=0)||(Y%400==0))
            {
                N--;
            }
            if(N==0)
                break;
            Y++;
        }
        printf("%d\n",Y);
    }
    return 0;
}
时间: 2024-10-11 05:59:57

HDU-1076-An Easy Task(Debian下水题測试.....)的相关文章

HDU-1076-An Easy Task(Debian下水题测试.....)

An Easy Task Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17062    Accepted Submission(s): 10902 Problem Description Ignatius was born in a leap year, so he want to know when he could hold h

HDU 1076 An Easy Task

对于闰年判断的题已经做过很多,但是这个题令我印象深刻. 刚开始,我的代码是 1 #include<stdio.h> 2 int is_leap(int n) 3 { 4 if((n%4==0&&n%100!=0)||n%400==0) 5 return 1; 6 else 7 return 0; 8 } 9 int main() 10 { 11 int m; 12 scanf("%d",&m); 13 int i; 14 int a,b; 15 fo

杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> /* 题意:找闰年. if((i%4==0 && i%100!=0) || i%400==0)count++; 3 2005 25 1855 12 2004 10000 2108 1904 43236 */ int main() { int t,y,n; int i,count=0; whil

哈理工2015暑假训练赛BNU16488 Easy Task(简单题)

A - Easy Task Time Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu SubmitStatusPracticeZOJ 2969 Description Calculating the derivation of a polynomial is an easy task. Given a function f(x) , we use (f(x))' to denote its derivatio

(HDU)1076 --An Easy Task(简单任务)

题目链接:http://vjudge.net/problem/HDU-1076 数据规模小,直接枚举过去. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 6 int main() 7 { 8 int t,y,n,i,ans; 9 scanf("%d",&t); 10 while(t--) 11 { 12 scanf

HDOJ 1076 An Easy Task

[题意]:输入两个数,Y和N.输出从Y(如果Y是闰年则包含Y)开始的第N个闰年. [代码:AC] #include <iostream> #include <iomanip> #include <cstring> #include <cstdlib> #include <cstdio> using namespace std; int isLeapYear(int year) { if ((year%4 == 0 && year%

九度OJ 1006 ZOJ问题 (这题測试数据有问题)

题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:15725 解决:2647 题目描写叙述: 对给定的字符串(仅仅包括'z','o','j'三种字符),推断他能否AC. 是否AC的规则例如以下: 1. zoj能AC: 2. 若字符串形式为xzojx,则也能AC.当中x能够是N个'o' 或者为空: 3. 若azbjc 能AC,则azbojac也能AC.当中a,b,c为N个'o'或者为空: 输入: 输入包括多组測试用例,每行有一个仅仅包括'z','o','j'三种字

An Easy Task(简箪题)

B. An Easy Task Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class name: Main Submit Status PID: 35999 Font Size:  +   - You are given an easy task by your supervisor -- to find the best va

HDU 1862 EXCEL排序 (排序水题)

Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号.以下有 N 行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,同组测试中没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开.当读到 N=0 时,全部输入结