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==0return 1;
    
if(Y%4==0 && Y%100!=0return 1;
    
return 0;
}


int main()
{
    cin
>>Y;
    
while(Y!=0)
    
{    
        
if(Leap()) cout<<"yes"<<endl;
        
else cout<<"no"<<endl;
        cin
>>Y;
    }

}


原创粉丝点击