Leap Year Check
Python
Easy
4 views
Problem Description
Read a year y, output YES if it is a leap year else NO. Leap year rule: divisible by 400 or divisible by 4 but not by 100.
Input Format
One integer y.
Official Solution
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
y=int(s)
leap=(y%400==0) or (y%4==0 and y%100!=0)
sys.stdout.write('YES' if leap else 'NO')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!