Minimum Divisible Sequence
Limits: 2 sec., 512 MiB
You are given an integer \(n\).
Construct an integer sequence \(a\) of length \(m\) satisfying the following conditions.
\(1 \le a_i \le n\) for all \(1 \le i \le m\).
For each \(1 \le k \le n\), there exists \(1 \le i \le m\) such that \(a_i\) is a multiple of \(k\).
The length \(m\) is minimum possible.
Input
The single line contains an integer \(n\).
Output
In the first line print an integer \(m\) – the length of the sequence \(a\).
In the second line print \(m\) integers \(a_i\) – the elements of the sequence.
If there are multiple answers, any of them will be accepted.
Constraints
\(1 \le n \le 10^5\).
Samples
Input (stdin) | Output (stdout) |
---|---|
7 | 4 4 7 5 6 |
Notes
In the example, one of the possible sequences is \(a = (4, 7, 5, 6)\).
\(a_1 = 4\) is a multiple of \(1\).
\(a_1 = 4\) is a multiple of \(2\).
\(a_4 = 6\) is a multiple of \(3\).
\(a_1 = 4\) is a multiple of \(4\).
\(a_3 = 5\) is a multiple of \(5\).
\(a_4 = 6\) is a multiple of \(6\).
\(a_2 = 7\) is a multiple of \(7\).
It is impossible to construct a sequence satisfying the conditions of length less than four.
Submit a solution
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|