#P5737. Counting Leap Years in an Interval

    ID: 18965 Type: Default 1000ms 256MiB

Counting Leap Years in an Interval

Counting Leap Years in an Interval

You are given two integers x and y. Your task is to count the number of leap years in the closed interval \([x, y]\) and output these count, followed by a list of the leap years separated by a space on the next line. A year \(Y\) is considered a leap year if it is divisible by \(400\), or if it is divisible by \(4\) but not divisible by \(100\).

inputFormat

The input consists of two integers x and y separated by space, representing the interval \([x, y]\). It is guaranteed that \(x \le y\).

outputFormat

The first line should output the number of leap years in the interval \([x, y]\). The second line should output all the leap years in the interval, separated by a space.

sample

2000 2020
6

2000 2004 2008 2012 2016 2020

</p>