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. 重新想象 Windows 8 Store Apps (30) - 信息: 获取包信息, 系统信息, 硬件信息, PnP信息, 常用设备信息

    原文:重新想象 Windows 8 Store Apps (30) - 信息: 获取包信息, 系统信息, 硬件信息, PnP信息, 常用设备信息 [源码下载] 重新想象 Windows 8 Store ...

  2. 【原创】纯OO:从设计到编码写一个FlappyBird (三)

    第二部分请点这里 下面首先来实现Bing接口! 实现Bing接口的类取名SimpleBing. 容易发现,SimpleBing类总的来说要向下,但点击一下又得向上,向上到了一定界限又得向下,但我们又只 ...

  3. C# 几种方法来复制的阵列

    突然接触到,所以就写一下共享. 首先说明一下,数组是引用类型的,所以注意不要在复制时复制了地址而没有复制数值! 事实上在复制数组的时候.一定要用new在堆中开辟一块新的空间专门用于存放数组.这样才是有 ...

  4. 四个漂亮CSS样式表

    1. 单像素的边框CSS表格 这是一个非常所用的表格风格. 源码: <!-- CSS goes in the document HEAD or added to your external st ...

  5. 创建Oracle的用户 create user scott identified by tiger;

    在命令行里sqlplus 以system身份登录,password是自己设的system C:\Users\Administrator>sqlplus SQL*Plus: Release 10. ...

  6. JAVA环境配置---------jdk安装路径中存在空格的问题

    我把jdk 安装在C:\Program Files下 而ide启动脚本 startup.bat 例如以下: if "%OS%"=="Windows_NT" se ...

  7. cocospods 卡在 Analyzing dependencies

    參考链接:http://www.cocoachina.com/bbs/read.php? tid=193398 关于pod stetup的详解在这里.对于初次使用CocoaPods的同学,即使你不使用 ...

  8. 从XML文件乱码问题,探寻其背后的原理(转)

    由于网友反应本文图片不能显示,由于时间关系未能及时修正.请访问原文地址: 本文出自http://blog.csdn.net/dinglang_2009/article/details/6895355, ...

  9. POJ 1699 Best Sequence (DFS+预处理)

    意甲冠军:看图片是晶莹剔透的,正确的, N连接到第一序列(同样的序列部分).总序列获得最短. 主题链接:http://poj.org/problem?id=1699 ~~~~ 思路就是:将N个序列首尾 ...

  10. RH133读书笔记(7)-Lab 7 Advanced Filesystem Mangement

    Lab 7 Advanced Filesystem Mangement Goal: Develop skills and knowlege related to Software RAID, LVM, ...