Triple XOR
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
You are given two positive integers \(m<n\). What is the maximum number of pairwise distinct integers that can be chosen from the interval \([m, n]\) such that the following condition is satisfied:
There are no three distinct chosen numbers \(x, y, z\) such that \(x \oplus y \oplus z = 0\).
Recall that \(\oplus\) denotes the
bitwise exclusive OR operation. For example, \(13 \oplus 6 = 11\), because in binary \(13 =\) 1101, and \(6 =\) 0110, so their \(\oplus\) is equal to 1011
\(= 11\).
Input
The only line of input contains two positive integers \(m, n\).
Output
In the first line, output the number \(k\) — the maximum number of integers that can be chosen satisfying the problem condition.
In the second line, output \(k\) pairwise distinct integers \(a_1, a_2, \ldots, a_k\), \(m \leq a_i \leq n\). They must satisfy the problem condition.
If there are several different ways to choose the maximum possible number of integers, find any of them.
Constraints
\(1 \leq m < n \leq 2\cdot 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 1 7 | 4 1 3 5 7 |
| Input (stdin) | Output (stdout) |
|---|---|
| 2024 2025 | 2 2025 2024 |
Notes
In the first example, it can be shown that choosing \(5\) numbers from the interval \([1, 7]\) in this way is impossible.
In the second example, among \([2024, 2025]\) there are no three distinct numbers, so the condition is satisfied automatically.
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 |
|---|