No.1871 divisXor
タグ : / 解いたユーザー数 98
作問者 :
shiomusubi496
Problem Statement
Define $f(x)$ as the sum of the positive divisors of $x$, and $a \oplus b$ as the bitwise XOR of $a$ and $b$.
You are given a non-negative integer $N$. Construct $1$ sequence of positive integers $A = (A_1, A_2, \ldots, A_M)$ that satisfies the following conditions.
- $1 \le M \le 100$
- $f(A_1) \oplus f(A_2) \oplus \cdots \oplus f(A_M) = N$
- $A_1 + A_2 + \cdots + A_M \lt 2 \times N$
- The elements of $A$ are pairwise distinct
However, if no $A$ satisfying the conditions exists, output $-1$.
Input
$N$
- $N$ is an integer
- $0\le N\le 10^{12}$
Output
If an $A$ satisfying the conditions exists, output it in the following format.
$M$ $A_1$ $A_2$ $\cdots$ $A_M$
If no $A$ satisfying the conditions exists, output $-1$ on a single line.
Sample
Sample 1
Input
17
Output
3 1 6 12
We have $f(1) \oplus f(6) \oplus f(12) = 1 \oplus 12 \oplus 28 = 17$. Also, $1 + 6 + 12 = 19 \lt 2 \times 17 = 34$, so the conditions are satisfied.
Sample 2
Input
0
Output
-1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。