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. UVa 12459 - Bees&#39; ancestors

    称号:区区女性有父亲和母亲,区区无人机只有一个母亲,我问一个单纯的无人机第一n随着祖先的数量. 分析:递归.Fib序列. 状态定义:建立f(k)和m(k)分别用于第一k雌蜂和雄蜂的数量: 递推关系:f ...

  2. JAVA jdbc(数据库连接池)学习笔记(转)

    学习内容: 1.JDBC的含义... JDBC想必学过JAVA的就不会陌生,JDBC到底是什么呢?其实就是由JAVA的一些类和接口构成的API,保存在java.sql和javax.sql..包中的一些 ...

  3. javascript焦点图(能够自己主动切换 )

    /* 思路总结: 1.实现图片滚动的function.鼠标经时候获取当前li的index.设置ndex自己主动递增的函数.实现淡入淡出效果的函数 2.整个实现效果一传递index为主线 3.我的编写代 ...

  4. 从头开始建网站(三)DNS

    前面介绍了站点搭建所须要的两大要素:域名和server,这次要说的是域名解析,也就是把域名和server进行绑定的过程. 我们在訪问网络时,网址会被发送到DNSserver,然后由DNSserver返 ...

  5. UVa 11069 - A Graph Problem

    题目:给你一个集合{1,2,..,n},计算子集的个数,子集的元素不能相邻且不能再插入元素. 分析:dp,动态规划.相邻元素间仅仅能相差3或者2. 动态方程:f(k)= f(k-2)+ f(k-3): ...

  6. 华为OJ:查找字符的第一个字符串只出现一次

    您可以使代码有点写得真好,不要直接写双循环,如果,是可能的写函数调用,非常高的可重用性. import java.util.Scanner; public class findOnlyOnceChar ...

  7. FastReport扩展类

    题记: 最近有在用FastReport进行开发报表工作,当然也有在看书,突然想到可以用书中所写来实现一个fastreport的帮助类. 对于引用第三方类库,我们都会去将这个库在调用前进行相应的封装,也 ...

  8. NetBeans工具学习之道:NetBeans IDE Java 高速新手教程

    欢迎使用 NetBeans IDE! 本教程通过指导您创建一个简单的 "Hello World" Java 控制台应用程序,简要介绍 NetBeans IDE 工作流.学习完本教程 ...

  9. HDU ACM 1290 献给杭电五十周年校庆的礼物

    解析: 1.n条直线把平面切割成的区域数为: f(n)=f(n-1)+n=n(n+1)/2+1; 2.把空间切割为最多区域数的时候,第n个平面与前(n-1)个平面相交.且无三面共线,因此该平面与前(n ...

  10. 【甘道夫】HBase连接池 -- HTablePool是Deprecated之后

    说明: 近期两天在调研HBase的连接池,有了一些收获,特此记录下来. 本文先将官方文档(http://hbase.apache.org/book.html)9.3.1.1节翻译,方便大家阅读,然后查 ...