首页 > 其他分享 >HDOJ1076 An Easy Task

HDOJ1076 An Easy Task

时间:2023-02-20 10:37:43浏览次数:33  
标签:Task scanner int HDOJ1076 leap Easy year test cases


An Easy Task


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24613    Accepted Submission(s): 15866


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


Hint


给出其实年份,求该年份的第N个闰年,计算闰年的方法都给了


import java.util.Scanner;

public class Main{
private static Scanner scanner;
public static void main(String[] args) {
scanner = new Scanner(System.in);
int cases = scanner.nextInt();
while(cases-->0){
int year = scanner.nextInt();
int m = scanner.nextInt();
int count = 0,i = 0;
while(count<m){
if(judgeYear(year+i)){
count++;
}
i++;
}
System.out.println(year+i-1);
}
}
private static boolean judgeYear(int i) {
if((i%4==0 && i%100!=0 )|| i%400 == 0){
return true;
}
return false;
}
}



标签:Task,scanner,int,HDOJ1076,leap,Easy,year,test,cases
From: https://blog.51cto.com/u_15741949/6067718

相关文章

  • HDOJ2132 An easy problem
    AneasyproblemTimeLimit:3000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):14373    AcceptedSubmission(s)......
  • redux 对thunk的补充(createAsyncThunk和extraReducers)
    补充thunk的编写模式上个章节,我们提到了thunk。我想了一下,有一个重点没说。1.reducer就是用于处理数据的逻辑2.reducer中不能放置任何异步的逻辑基于上面两点,thunk必......
  • jeasyui,jquery某些经常使用方法
    tabs判断是否打开某个页签varflag=$('#center_tab').tabs('exists',menuName);从一个子页面中得到父页面的另一个子页面(iframe)的jeasyui的元素parent.frames["......
  • iframe中获得父页面的easyUi控件
    这种写法可以获取控件对象,但是不能做任何操作。很奇怪。。。$("#currentId",parent.document 换成此写法即可varnode=parent.$('#groupTree').tree('getSelected')......
  • Timer,TimerTask的用法
    以前都用quartz来做定时任务,现接手一个项目,里面用的是jdk自带的Timer,所以学习并记录下 每两秒执行一次helloworld packagecom.mhm.test;importjava.util.TimerTask;pub......
  • jeasyui 弹出遮罩层
    此遮罩用的是jeasyui源码里的: <html><head><scriptsrc="jquery-1.8.0.min.js"type="text/javascript"></script><scriptsrc="jquery.json-2.4.js"......
  • [oeasy]python0086_ASCII_出现背景_1963年_DEC_PDP系列主机_VT系列终端
    编码进化回忆上次内容上次回顾了字符编码的新陈代谢ibm曾经的EBCDIC由于字符不连续导致后续出现无数问题随着网络的发展数据交换的需要原来的小隐患现在产生了......
  • [oeasy]python0086_ASCII_出现背景_1963年_DEC_PDP系列主机_VT系列终端
    编码进化回忆上次内容上次回顾了字符编码的新陈代谢ibm曾经的EBCDIC由于字符不连续导致后续出现无数问题随着网络的发展数据交换的需要原来的......
  • easyui入门
    控件:创建方法:一、标签模式<ahref='#'class='easyui-linkbutton'data-options="iconCls:'icon-search'">easyui入门</a>二、编程模式<ahref="#"class="hehe">第......
  • CLIP-TD: CLIP Targeted Distillation for Vision-Language Tasks论文阅读笔记
    CLIP-TD:CLIPTargetedDistillationforVision-LanguageTasks论文阅读笔记摘要这是一篇关于利用CLIP模型来提升视觉语言任务性能的论文。CLIP模型是一个可以从大量图......