atcoder 之February 29th
来源:互联网 发布:模拟退火算法的优缺点 编辑:程序博客网 时间:2024/06/04 00:23
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(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
- 2008 February 29th Wednesday (二月 二十九日 金曜日)
- atcoder 1th C
- February 3th Wednesday 2010
- February 4th Tuesday 2010
- February 5th Friday 2010
- February 23th Tuesday 2010
- February 24th Wednesday 2010
- February 26th Friday 2010
- February 6th Tuesday (一月 六日 火曜日)
- Lightoj 1414 - February 29
- lightoj 1414 February 29
- UVa 12439 - February 29
- 【Lightoj 1414 - February 29 】
- lightoj 1414 - February 29
- lightpoj-【February 29】
- February 5th Monday (一月 五日 月曜日)
- 2008 February 4th Monday (二月 四日 月曜日)
- bzoj 2326: [HNOI2011]数学作业
- Linux下运行多线程——undefined reference to 'pthread_create'问题两种解决方法
- 【国庆六十五年纪念毛主席】诗一首
- 红帽5.4企业版上yum的安装和配置
- Linux交叉工具链的安装
- atcoder 之February 29th
- 三种Div高度自适应的方法
- webView
- C/C++中 static 用法总结
- 内存管理
- 常见字体清单
- struts2返回json数据的具体范例
- OC中单例的实现方法
- keil warning: #1-D: last line of file ends without a newline