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(AB≦2,000,000,000), when he leaves the Earth.

Achievements and Points

  • When you pass every test case where 1≦AB≦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

  1. 1988 2014

Output Example 1

  1. 7

Charlie can pass February 29th of 1988199219962000200420082012.
The total is 7 times.


Input Example 2

  1. 997 1003

Output Example 2

  1. 0

Note that the year 1000 is NOT a
leap year.


Input Example 3

  1. 1 2000000000

Output Example 3

  1. 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的更多相关文章

  1. Spark版本发布历史,及其各版本特性

      2016年11月5日 We are proud to announce that Apache Spark won the 2016 CloudSort Benchmark (both Dayto ...

  2. Hot resize Multipath Disk – Linux

    This post is for the users of the great dm-multipath system in Linux, who encounter a major availabi ...

  3. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  4. AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识

    链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...

  5. Hackerrank 2020 February 2014 解题报告

    Hackerrank 2020 February 2014 解题报告 比赛链接 Sherlock and Watson (20分) 题意:给定一个数组,向右平移K次,然后有Q个询问,问第x位置上是几 ...

  6. February 29(模拟)

    D - D Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status P ...

  7. AtCoder Regular Contest 082

    我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...

  8. AtCoder Regular Contest 069 D

    D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...

  9. AtCoder Regular Contest 076

    在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...

随机推荐

  1. 丢弃重口味的xml配置--spring4用groovy配置bean(转)

    spring4之前,bean的配置可以主要分为两种方式,一种是使用基于xml,个人非常讨厌这种方式,因为明明一件很简单的事,放在xml中就会多了不少繁杂的信息.另一种方式,是从spring3.0开始, ...

  2. HttpClient使用具体解释

    Http协议的重要性相信不用我多说了,HttpClient相比传统JDK自带的URLConnection,添加�了易用性和灵活性(详细差别,日后我们再讨论),它不仅是client发送Http请求变得e ...

  3. Sqlserver中Over函数

    Over函数不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用.  其参数:over(partition by columnname1 order ...

  4. ios pop 折叠动画

    今天写了一个很有趣的电影太,我们可以去githoub下载. 这部动画是高级写作,我参考了它.而凝视,我希望你能看的懂. 各种动画.事实上,一些不起眼的开始.我也只是摸索. 我希望有更多的交流.[   ...

  5. CentOS7 已安装telnet维修

    今天搞下 Centos 7 以下升级 openssl 和 openssh ,顺便说下安装 telnet # 设备 telnet 避 ssh 无法登录 yum -y install xinetd tel ...

  6. Directx11学习笔记【十二】 画一个旋转的彩色立方体

    上一次我们学习了如何画一个2D三角形,现在让我们进一步学习如何画一个旋转的彩色立方体吧. 具体流程同画三角形类似,因此不再给出完整代码了,不同的部分会再说明. 由于我们要画彩色的立方体,所以顶点结构体 ...

  7. Java代码检查工具

    FindBugs:不注重样式和格式,重视真正的缺陷和潜在的性能问题,,基于Bug Patterns,在不运行的情况下检查字节码代码质量. Jalopy:Java源代码格式化工具,可自定义规则. PMD ...

  8. 【剑指offer】第一个字符只出现一次

    转载请注明出处:http://blog.csdn.net/ns_code/article/details/27106997 题目描写叙述: 在一个字符串(1<=字符串长度<=10000,所 ...

  9. iOS 自己主动布局教程

    springs和struts的问题 你肯定非常熟悉autosizing masks-也被觉得是springs&struts模式.autosizing mask决定了当一个视图的父视图大小改变时 ...

  10. shell编程三大神器之grep