1 条题解
-
0
题解见注释
import java.util.Scanner; public class P1008 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //输入处理 int count = sc.nextInt(); for (int i = 0; i < count; i++) { int nowYear = sc.nextInt(); int toNextLeapYearNum = sc.nextInt(); //j代表已经过去的闰年的数量,是闰年j就+1知道符合需求 //每次循环年份从nowYear开始进行+1循环,知道j满足条件 for (int j = 0; j < toNextLeapYearNum; nowYear++) { if(LeapYearJudgement(nowYear)){ j++; } } //由于for循环最后一次循环结束的时候会额外执行一次nowYear++,在这里修正 int aws = nowYear-1; System.out.println(aws); } } //闰年判断 public static boolean LeapYearJudgement(int year){ if(year % 4 == 0){ if(year % 100 == 0){ return year % 400 == 0; }else { return true; } }else { return false; } } }
- 1
信息
- ID
- 9
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- 10
- 标签
- 递交数
- 6
- 已通过
- 2
- 上传者