Leap Year
InterviewTime limit1sMemory limit128 MB
Given a year, output 1 if it is a leap year according to the standard divisibility rule, otherwise output 0.
- Level
Easy1 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Given a year, write a program that prints 1 if the year is a leap year and 0 otherwise.
A leap year is a year that is divisible by 4 but not divisible by 100, or a year that is divisible by 400.
For instance, 2012 is divisible by 4 and not by 100, so it is a leap year. The year 1900 is divisible by 100 but not by 400, so it is not a leap year. The year 2000 is a leap year because it is divisible by 400.
Input
The first line contains a year. The year is a natural number between 1 and 4000, inclusive.
Output
Print 1 if the given year is a leap year; otherwise, print 0.