#CCBOTPBA0000049. Liệt kê các năm nhuận trong đoạn (List Leap Years in an Interval)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Liệt kê các năm nhuận trong đoạn (List Leap Years in an Interval)
List Leap Years in an Interval
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given two Gregorian calendar years and with , list all leap years from through , including both endpoints. A year is a leap year if it is divisible by , or if it is divisible by but not by . If the interval contains no leap year, print NONE.
Input
One line contains two integers and , in this order.
Output
Print all leap years in increasing order, one per line. If there are none, print a single line NONE.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Example 1
Input:
1896 1904
Output:
1896
1904
Explanation: 1896 is divisible by 4 but not 100. 1900 is divisible by 100 but not 400, so it is excluded. 1904 is a leap year. Therefore two lines are printed.
Example 2
Input:
2000 2000
Output:
2000
Explanation: The year 2000 is divisible by 400, so it is a leap year even though it is also divisible by 100.
Example 3
Input:
1900 1903
Output:
NONE
Explanation: 1900 is not leap; 1901, 1902 and 1903 are not divisible by 4. Hence there is no leap year.