fjnu 1285 Leap Years
来源:互联网 发布:端口号查询 linux 编辑:程序博客网 时间:2024/05/18 00:13
Description
Leap days are added to compensate for the tropical year of the earth being slightly longer than 365 days. Years in which these leap days are added have, naturally, been called leap years, which were first introduced in the Julian calendar in 46 BC. The intent was that every fourth year would be a leap year. However, there was a screwup early on causing leap years to (incorrectly) be added every three years (hence 42 BC, 39 BC, etc were all leap years). This was corrected by skipping a few leap years (4 AD is *not* a leap year despite what cal says).
Unfortunately, this compensation still isn't quite right as it over compensates. The Gregorian calendar fixed this (by the way; the switchover from Julian to Gregorian created some interesting calendars, which we won't get into here, but check out Sept. 1752 in cal sometime). The fix was to declare that every year divisible by 100 is *not* a leap year. Unfortunately (again) the fix to the fix isn't quite right. The fix to the fix to the fix is that years divisible by 100 are not leap years, except if the year is divisible by 400 in which case it is. As far as I know there is not a fix to the fix to the fix to the fix to compensate for any remaining inaccuracies.
In this problem, you'll be given a year and asked to determine if it is a leap year. For our purposes all years divisible by 4 and not by 100 are leap years. Any year divisible by 100 and by 400 are also leap years. Anything else is not a leap year.
Input
The input consists of various years. The smallest year will be 1800 to avoid the ugliness of Gregorian calendar switchover and the early mess ups in calculating the leap years. The largest value will 2 billion (despite the end of the 13th Baktun in the Mayan calendar in 2012, which prophesies the end of the fourth and final age). Input is terminated by a 0, which, obviously, should not be processed.
Output
For each year, print out `yes' if it is a leap year and `no' if it isn't.
Sample Input
2012200019000
Sample Output
yesyesno
KEY:leap的看能不能被400整除,能不是被4且不能被100整除;
Source:#include<iostream>
using namespace std;
int Y;
int Leap()
...{
if(Y%400==0) return 1;
if(Y%4==0 && Y%100!=0) return 1;
return 0;
}
int main()
...{
cin>>Y;
while(Y!=0)
...{
if(Leap()) cout<<"yes"<<endl;
else cout<<"no"<<endl;
cin>>Y;
}
}
- fjnu 1285 Leap Years
- Leap Years
- Why are leap years used?
- FJNU
- LEAP YEAR!!!
- leap motion
- leap motion_unity
- Leap Motion
- Leap Motion
- FJNU字符串
- FJNU字符串
- fjnu 1772
- 25years
- 35years
- two years
- 10 Years
- leap学习笔记
- LEAP MOTION与MYO
- Oracle的Numer类型与C,C#数据类型对应关系
- fjnu 1452 辉辉的一天
- URL重写后页面回发相关问题
- 一道Unix面试题
- fjnu 1250 Beat the Spread!
- fjnu 1285 Leap Years
- 理论研讨]中国经济会在2008年崩溃吗?
- 郁闷,这么久才发现看错了书
- fjnu 1304 蛇行矩阵
- fjnu 1406 输入三个自然数
- Sony CM-H333 ESN 软件的接口图
- fork函数与vfork函数
- 《深入浅出MFC》学习笔记(1)
- fjnu 1902 排排序