#C2634. Rich Numbers

    ID: 45972 Type: Default 1000ms 256MiB

Rich Numbers

Rich Numbers

Given a positive integer \(n\) (the upper limit), your task is to determine all rich numbers less than or equal to \(n\). A rich number is defined as an integer greater than 1 that can be expressed as the sum of two positive integers in at least two distinct ways. In other words, there exist at least two pairs \((a, b)\) with \(a < b\) such that \(a + b = n\).

For example, \(5\) is a rich number since \(5 = 1 + 4\) and \(5 = 2 + 3\), whereas \(4\) is not rich because it has only one representation: \(4 = 1 + 3\). The order of the terms does not matter, so \((1,4)\) is considered the same as \((4,1)\).

inputFormat

The input consists of a single integer (n) provided via stdin, which represents the upper limit. Use this value to generate all rich numbers (\leq n).

outputFormat

Output a sequence of rich numbers in increasing order separated by a single space to stdout. If there are no rich numbers, output an empty line.## sample

10
5 6 7 8 9 10

</p>