Dễ 0 đã giải Tỷ lệ chấp nhận 0%

Leap Year

Check whether a year follows the Gregorian leap-year rule.

A year divisible by 4 is a leap year unless it is also divisible by 100. Years divisible by 400 are leap years despite that exception. Apply this arithmetic rule to every allowed input year.

Implement leap_year(year).

Input

year: The year to check.

Output

Return true for a leap year and false otherwise.

Ràng buộc

1 ≤ year ≤ 9999.

Ví dụ

Ví dụ 1
Đầu vào:
year = 2024

Kết quả mong đợi:
expected = True
Đầu vào:
long long year = 2024;

Kết quả mong đợi:
bool expected = true;
Đầu vào:
long year = 2024;

Kết quả mong đợi:
bool expected = true;

Giải thích

2024 is divisible by 4 and not by 100.

Ví dụ 2
Đầu vào:
year = 2100

Kết quả mong đợi:
expected = False
Đầu vào:
long long year = 2100;

Kết quả mong đợi:
bool expected = false;
Đầu vào:
long year = 2100;

Kết quả mong đợi:
bool expected = false;

Giải thích

2100 is divisible by 100 but not by 400, so the century exception applies.

Tham khảo

Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.

Học hỏi từ người khác

Giải pháp cộng đồng

Chưa có giải pháp nào được chia sẻ. Hãy giải thử thách này để đăng giải pháp đầu tiên.