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只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...
随机推荐
- Linux注意到Makefile
规则: 目标 : 依靠 命令 make是怎样工作的: (1)make在当前文件夹下寻找makefile或Makefile. (2)假设找到,他会寻找文件里的第一个目标文件(target).并把这个文件 ...
- 令人无限遐想的各种PCIe加速板卡
声明 本文不涉及不论什么特定API,也不针对不论什么特定的厂商,可是仍然值得透露一点的是,某些加速板卡厂商的成功点和失败点恰恰都是在于其通用性,在这个人们依旧依赖专业板卡的时代,依旧将板卡视为解决专业 ...
- C#并行编程
C#并行编程中的Parallel.Invoke 一.基础知识 并行编程:并行编程是指软件开发的代码,它能在同一时间执行多个计算任务,提高执行效率和性能一种编程方式,属于多线程编程范畴.所以我们在设计过 ...
- chrome 关闭自己主动更新
一不小心,把chrome更新成了37, chrome 37不支持模态窗体[ window.showModalDialog() ],折腾死人了. 实在抵不住,仅仅好降级成36.0.1985.143m 至 ...
- hdu 5074 相邻的和最大dp
http://acm.hdu.edu.cn/showproblem.php?pid=5074 给定一个序列 有些位数未知,给你全部两个数连续所得到的能量.问你怎么安排数字使得总能量最大 二维dp,dp ...
- 深入理解学习Git工作流(转)
个人在学习git工作流的过程中,从原有的 SVN 模式很难完全理解git的协作模式,直到有一天我看到了下面的文章,好多遗留在心中的困惑迎刃而解,于是我将这部分资料进行整理放到了github上,欢迎st ...
- yate.conf
但档案.粘贴下面的例子.不解释!除去非常灵活!只保留sip电话! [general] ; General settings for the operation of Yate ; modload: b ...
- POJ 1984 Navigation Nightmare (数据结构-并检查集合)
Navigation Nightmare Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 4072 Accepted: 1 ...
- 【Swift】学习笔记(四)——设置(Collection)
Swift和其他语言也提供了两种类型的集合:数组和字典 数组:数组用来按顺序存储同样类型的数据,swift规定它是类型安全的,每个数组都有自己的类型也就是其它语言所说的泛型. 创建数组: 1.var ...
- [Python学习] 模块三.基本字符串
于Python最重要的数据类型包含字符串.名单.元组和字典.本文重点介绍Python基础知识. 一.字符串基础 字符串指一有序的字符序列集合,用单引號.双引號.三重(单 ...