Divide by Zero 2018 and Codeforces Round 474 (Div. 1 + Div. 2, combined)
C
Subsequence Counting
Codeforces
1700
原题
← BD →
翻译中…

Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size $*n*$ has $2^{*n*} - 1$ non-empty subsequences in it.

翻译中…

Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence $-$ Minimum_element_of_subsequence $≥ *d*$

翻译中…

Pikachu was finally left with $*X*$ subsequences.

翻译中…

However, he lost the initial array he had, and now is in serious trouble. He still remembers the numbers $*X*$ and $*d*$. He now wants you to construct any such array which will satisfy the above conditions. All the numbers in the final array should be positive integers less than $10^{18}$.

翻译中…

Note the number of elements in the output array should not be more than $10^{4}$. If no answer is possible, print $- 1$.

翻译中…

Input

翻译中…

The only line of input consists of two space separated integers $*X*$ and $*d*$ ($1 ≤ *X*, *d* ≤ 10^{9}$).

翻译中…

Output

翻译中…

Output should consist of two lines.

翻译中…

First line should contain a single integer $*n*$ ($1 ≤ *n* ≤ 10 000$)— the number of integers in the final array.

翻译中…

Second line should consist of $*n*$ space separated integers — $*a*_{1}, *a*_{2}, ... , *a*_{*n*}$ ($1 ≤ *a*_{*i*} < 10^{18}$).

翻译中…

If there is no answer, print a single integer -1. If there are multiple answers, print any of them.

翻译中…

Note

翻译中…

In the output of the first example case, the remaining subsequences after removing those with Maximum_element_of_the_subsequence $-$ Minimum_element_of_subsequence $≥ 5$ are $[5], [5, 7], [5, 6], [5, 7, 6], [50], [7], [7, 6], [15], [6], [100]$. There are $10$ of them. Hence, the array $[5, 50, 7, 15, 6, 100]$ is valid.

翻译中…

Similarly, in the output of the second example case, the remaining sub-sequences after removing those with Maximum_element_of_the_subsequence $-$ Minimum_element_of_subsequence $≥ 2$ are $[10], [100], [1000], [10000]$. There are $4$ of them. Hence, the array $[10, 100, 1000, 10000]$ is valid.

翻译中…

样例

Input #1
10 5
Output #1
6
5 50 7 15 6 100
InputCopy OutputCopy
Input #2
4 2
Output #2
4
10 100 1000 10000
InputCopy OutputCopy
题目信息
题号
960C
时间限制
1 s
内存限制
256 MB
标签
位运算
构造
贪心
模拟

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