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
NOTa
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只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...
随机推荐
- 如何处理 Windows Phone 8 动态砖变成黑白砖
原文:如何处理 Windows Phone 8 动态砖变成黑白砖 ? 问题的来龙去脉 我的 Windows Phone 8 动态砖变成黑白砖,所有图示和文字变成黑白,该如何处理? ? 问题的发生原因 ...
- HDU 4288 Coder (线段树)
Coder 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4288 题意:有三种类型的操作,(1)."add x",表示往集合里加入�数 ...
- 最常用的动态sql语句梳理Mybatis(转)
公司项目中一直使用Mybatis作为持久层框架,自然,动态sql写得也比较多了,最常见的莫过于在查询语句中使用if标签来动态地改变过滤条件了.Mybatis的强大特性之一便是它的动态sql,免除了拼接 ...
- php 两个文件之间的相对路径的计算方法
php 两个文件之间的相对路径的计算方法 比如: 文件A 的路径是 /home/web/lib/img/cache.php 文件B的路径是 /home/web/api/img/show.php 那么. ...
- 图表引擎AChartEngine 二
这几天项目涉及到android图表绘制,网上找的Demo都是大同小异,也就如上篇博文所写的一样是基本函数的实现.可是所有能找到的Demo都和设计图不符.木有办法,Leader发话啦,万不得已的情况下不 ...
- MVC模式编程演示样本-登录认证(静态)
好,部分博客分享我的总结JSP-Servlet-JavaBean思想认识和三层编程模型的基本流程,ZH- CNMVC该示例实现演示的编程模式-登录身份验证过程,在这里,我仍在使用静态验证usernam ...
- EJB学习笔记
1 J2ee概述 J2ee是企业级的计算平台,它为分布式和基于组件的软件开发提供了一个“操作系统” Ant是什么工具?? EJB: 什么是EJB? 是一种server端组件结构,简化了开发分布式企 ...
- Caused by: org.springframework.beans.factory.BeanCreationException
1.错误原因 2014-7-13 17:36:57 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one J ...
- 1号店Interview小结
三大范式: 为了建立冗余较小.结构合理的数据库,设计数据库时必须遵循一定的规则.在关系型数据库中这种规则就称为范式.范式是符合某一种设计要求的总结.要想设计一个结构合理的关系型数据库,必须满足一定的范 ...
- RH133读书笔记(8)-Lab 8 Manage Network Settings
Lab 8 Manage Network Settings Goal: To build skills needed to manually configure networking Estimate ...