Toph easy problem( Proper Leap Years)

Question:

Proper Leap Years

Limits: 1s, 512 MB

Byang’s friend was asked to author a programming problem where the challenge was to identify if the input number represented a leap year. The toad he is, he messed up and ended up using an incorrect definition of leap years.
Byang, embarrassed by what his friend did, took it upon himself to prepare a leap years problem using the correct description.
In the Gregorian calendar, certain years have 366 days instead of 365. In such years, the month of February is extended to have 29 days (instead of 28 days). These years are known as leap years.
Leap years are years which are multiples of four (with the exception of centennial years not divisible by 400).
[From Wikipedia]
Given a year, determine if the year is a leap year.

Input

The input will contain a one integer Y (0 < Y < 9999).

Output

Print “Yes” if the year is a leap year, otherwise “No”.

Samples

InputOutput
2004
Yes



Solve in C:

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(((n%4)==0)&&((n%100)!=0)||((n%400)==0))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.