zoukankan      html  css  js  c++  java
  • (HDOJ 1076)An Easy Task

    An Easy Task
    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
    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
     

     AC  code:

     #include<stdio.h>

    int leapyear(int Y)
    {
        
        
    if((Y%4==0 && Y%100!=0|| (Y%400==0))
          
    return 1;
        
    else
          
    return 0;
    }

    int main()
    {
        
    int Y,N,n,count;
        scanf(
    "%d",&n);
        
    while(n--)
        {
            count
    =0;
            scanf(
    "%d%d",&Y,&N);
            
    while(count<N)
            {
                
    if(leapyear(Y))
                {
                  count
    ++;
                  Y
    ++;
                }
                
    else
                {
                    Y
    ++;
                } 
            }
            printf(
    "%d\n",Y-1);
        }
        
    }
    作者:cpoint
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    淘宝镜像安装方法
    vue项目 title处的小图标
    vue生成环境 访问路径配置
    element ui icon不展示
    vue 使用element-ui实现table表单列展示与隐藏
    通过id获取元素控制滚动位置回到顶部
    复杂传值
    vue 中el-card点击事件失效解决
    滚动条隐藏 兼容
    【javascript/PHP】当一个JavaScripter初次进入PHP的世界,他将看到这样的风景
  • 原文地址:https://www.cnblogs.com/cpoint/p/2015320.html
Copyright © 2011-2022 走看看