atcoder 它February 29th
Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB
Problem
Charlie was born January 1st of the year A,
on the Earth. He will leave the Earth on December 31st of the year B.
He wants to know how many times he passes February 29th on the Earth.
February 29th is a leap day. A year that contains a leap day is called a leap year. You can determine if a year is leap year or not by following rules.
- If the year is divisible by 4, it is a leap year except the following case.
- If the year is divisible by 100, it is
NOT
a
leap year except the following case. - If the year is divisible by 400, it is a leap year.
Output how many times Charlie passes February 29th on the Earth. Note that Charlie lives very long.
Input
The input will be given in the following format from the Standard Input.
A B
- On the first line, you will be given the year A(1≦A≦2,000,000,000), when Charlie born,
followed by a space and the year B(A≦B≦2,000,000,000), when he leaves the Earth.
Achievements and Points
- When you pass every test case where 1≦A≦B≦3,000 , you will be awarded 25 points.
- In addition, if you pass all the rest test cases you will be awarded 25 more points.
Output
Output how many times Charlie passes February 29th on the Earth in one line. Make sure to insert a line break at the end of the output.
Inout Example 1
- 1988 2014
Output Example 1
- 7
Charlie can pass February 29th of 1988, 1992, 1996, 2000, 2004, 2008, 2012.
The total is 7 times.
Input Example 2
- 997 1003
Output Example 2
- 0
Note that the year 1000 is NOT
a
leap year.
Input Example 3
- 1 2000000000
Output Example 3
- 485000000
Note that Charlie lives very long.
思路:这题就是求两个年份之间的闰年数目。简单题。直接上代码。
import java.util.Scanner; public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
int temp1=b/4-(a-1)/4;
int temp2=b/100-(a-1)/100;
int temp3=b/400-(a-1)/400;
System.out.println(temp1-temp2+temp3);
}
}
}
版权声明:本文博客原创文章,博客,未经同意,不得转载。
atcoder 它February 29th的更多相关文章
- Spark版本发布历史,及其各版本特性
2016年11月5日 We are proud to announce that Apache Spark won the 2016 CloudSort Benchmark (both Dayto ...
- Hot resize Multipath Disk – Linux
This post is for the users of the great dm-multipath system in Linux, who encounter a major availabi ...
- AtCoder Regular Contest 061
AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...
- AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识
链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...
- Hackerrank 2020 February 2014 解题报告
Hackerrank 2020 February 2014 解题报告 比赛链接 Sherlock and Watson (20分) 题意:给定一个数组,向右平移K次,然后有Q个询问,问第x位置上是几 ...
- February 29(模拟)
D - D Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status P ...
- AtCoder Regular Contest 082
我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...
- AtCoder Regular Contest 069 D
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...
- AtCoder Regular Contest 076
在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...
随机推荐
- uva 10671 - Grid Speed(dp)
题目链接:uva 10671 - Grid Speed 题目大意:给出N,表示在一个N*N的网格中,每段路长L,如今给出h,v的限制速度,以及起始位置sx,sy,终止位置ex,ey,时间范围st,et ...
- 查看linux信息
1.操作系统内核 cat /proc/version 2.操作系统版本 head -n 1 /etc/issue # 查看操作系统版本 3.查看cpu信息 more /proc/cpuinfo --- ...
- Android RxJava使用介绍(三) RxJava的操作符
上一篇文章已经具体解说了RxJava的创建型操作符.本片文章将继续解说RxJava操作符.包括: Transforming Observables(Observable的转换操作符) Filterin ...
- android 他们定义对话框
创建一个布局文件 my_dialog.xml <?xml version="1.0" encoding="utf-8"?> <Relative ...
- Eclipse——热键&Help
版权声明:本文博主原创文章.博客,未经同意不得转载.
- 使用HTML5 Canvas做些什么
百分比圆环进度条 // ----------------------------------------------------------- 柱状排行榜统计图 // ------------ ...
- 4.锁定--Java的LockSupport.park()实现分析
LockSupport类是Java6(JSR166-JUC)引入的一个类,提供了主要的线程同步原语. LockSupport实际上是调用了Unsafe类里的函数.归结到Unsafe里,仅仅有两个函数: ...
- NYOJ 118 路方案(第二小的跨越)
修路方案 时间限制:3000 ms | 内存限制:65535 KB 难度:5 描写叙述 南将军率领着很多部队,它们分别驻扎在N个不同的城市里,这些城市分别编号1~N.因为交通不太便利,南将军准备修 ...
- javascript中的“向量”
什么是向量 向量通常指一个有长度有方向的量.向量使所有的移动和空间行为更容易理解和在代码中实现.向量可以相加,缩放,旋转,指向某物体. 在javascript中,一个方向和长度(即向量)在二维空间中可 ...
- Block学习一门:基本使用,使用block包NSURLRequest异步请求
首先,看一下下面的代码: void (^myFirstBlock)(int theOne,int theTwo) = ^(int theOne,int theTwo){ NSLog(@"== ...