Atcoder February 29th

Source: Internet
Author: User

Time Limit: 2sec/stack limit: 256 MB/memory limit: 256 MB

Problem

Charlie was born January 1st of the yearA, On the Earth. He will leave the earth on December 31st of the yearB.

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 divisible4, It is a leap year before t the following case.
  • If the year is divisible100, It isNOTA leap year before t the following case.
  • If the year is divisible400, 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(1 hourAListen 2,000,000,000), When Charlie born, followed by a space and the year B(ABytesBListen 2,000,000,000), When he leaves the earth.
Achievements and points
  • When you pass every test case where1 TibABytesBLimit 3,000, You will be awarded25Points.
  • In addition, if you pass all the rest test cases you will be awarded25More 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 29th1988,1992,1996,2000,2004,2008,2012. The total is7Times.

Input Example 2
 
  1. 997 1003
Output Example 2
 
  1. 0

Note that the year1000IsNOTA leap year.

Input Example 3
 
  1. 1 2000000000
Output Example 3
 
  1. 485000000

Note that Charlie lives very long.

Train of Thought: This question is to find the number of leap years between that year, simple question, directly on the code.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.