PROBLEM 71
Medium

Leap Year

Programming Basics · C#

</>
STATUS Not solved

TASK

Problem

#71

An integer value is given. Determine whether the input satisfies the condition “Leap Year”. Print `YES` when it does and `NO` otherwise. Print the answer exactly in the required format; do not print input prompts or explanatory labels.

EXAMPLE

Example

Input
2024
Output
YES

LIMITS

Constraints

- Every token parsed with `int.Parse` is a valid 32-bit signed integer; test data avoid unintended overflow in the task's intended calculation.
- Input is syntactically valid for the task except where invalid input is deliberately being tested (for example a `TryParse`/validation exercise).
- Print only the required answer; do not add prompts, labels, debug text, or extra spaces/lines.
📖
LEARN Theory for this problem
+

This is a direct arithmetic transformation. Name the input values, translate the formula exactly into C# operators, store the intermediate result when it improves readability, and print only the final value. For **Leap Year**, the concrete requirement is: Determine whether the input satisfies the condition “Leap Year”. Print `YES` when it does and `NO` otherwise. Keep input parsing, the core operation, and output formatting separate so each part can be checked independently.

💡
NEED HELP? Hints
+

['This is a direct arithmetic transformation. Name the input values, translate the formula exactly into C# operators, store the intermediate result when it improves readability, and print only the final value.', "Write the exact input-to-output rule for this task before coding: Determine whether the condition Leap Year holds for the input and print the task's required boolean form (for example `YES`/`NO` when shown by the examples).", 'Trace the public example by hand, then test the smallest input and the edge case most likely to change an index, branch, tie, or empty result.']

ANSWER Solution
+
using System;
class Program
{
    static void Main()
    {
        int y=int.Parse(Console.ReadLine());
        bool ok=y%400==0||(y%4==0&&y%100!=0);
        Console.WriteLine(ok?"YES":"NO");
    }
}