Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2)
C
Divisor Chain
Codeforces
1300
原题
← BD →
翻译中…

You are given an integer $x$. Your task is to reduce $x$ to $1$.

翻译中…

To do that, you can do the following operation:

翻译中…
  • select a divisor $d$ of $x$, then change $x$ to $x-d$, i.e. reduce $x$ by $d$. (We say that $d$ is a divisor of $x$ if $d$ is an positive integer and there exists an integer $q$ such that $x = d \cdot q$.)
翻译中…

There is an additional constraint: you cannot select the same value of $d$ more than twice.

翻译中…

For example, for $x=5$, the following scheme is invalid because $1$ is selected more than twice: $5\xrightarrow{-1}4\xrightarrow{-1}3\xrightarrow{-1}2\xrightarrow{-1}1$. The following scheme is however a valid one: $5\xrightarrow{-1}4\xrightarrow{-2}2\xrightarrow{-1}1$.

翻译中…

Output any scheme which reduces $x$ to $1$ with at most $1000$ operations. It can be proved that such a scheme always exists.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.

翻译中…

The only line of each test case contains a single integer $x$ ($2\le x \le 10^{9}$).

翻译中…

Output

翻译中…

For each test case, output two lines.

翻译中…

The first line should contain an integer $k$ ($1 \le k \le 1001$).

翻译中…

The next line should contain $k$ integers $a_1,a_2,\ldots,a_k$, which satisfy the following:

翻译中…
  • $a_1=x$;
  • $a_k=1$;
  • for each $2 \le i \le k$, the value $(a_{i-1}-a_i)$ is a divisor of $a_{i-1}$. Each number may occur as a divisor at most twice.
翻译中…

Note

翻译中…

In the first test case, we use the following scheme: $3\xrightarrow{-1}2\xrightarrow{-1}1$.

翻译中…

In the second test case, we use the following scheme: $5\xrightarrow{-1}4\xrightarrow{-2}2\xrightarrow{-1}1$.

翻译中…

In the third test case, we use the following scheme: $14\xrightarrow{-2}12\xrightarrow{-6}6\xrightarrow{-3}3\xrightarrow{-1}2\xrightarrow{-1}1$.

翻译中…

样例

Input #1
3
3
5
14
Output #1
3
3 2 1
4
5 4 2 1
6
14 12 6 3 2 1
InputCopy OutputCopy
题目信息
题号
1864C
时间限制
1 s
内存限制
256 MB
标签
位运算
构造
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。