CF960C.Subsequence Counting

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn has 2n12^{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>=d

Pikachu was finally left with XX subsequences.

However, he lost the initial array he had, and now is in serious trouble. He still remembers the numbers XX and dd . 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 101810^{18} .

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

输入格式

The only line of input consists of two space separated integers XX and dd ( 1<=X,d<=1091<=X,d<=10^{9} ).

输出格式

Output should consist of two lines.

First line should contain a single integer nn ( 1<=n<=100001<=n<=10000 )— the number of integers in the final array.

Second line should consist of nn space separated integers — a1,a2,... ,ana_{1},a_{2},...\ ,a_{n} ( 1<=ai<10181<=a_{i}<10^{18} ).

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

输入输出样例

  • 输入#1

    10 5
    

    输出#1

    6
    5 50 7 15 6 100
  • 输入#2

    4 2
    

    输出#2

    4
    10 100 1000 10000

说明/提示

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>=5 are [5],[5,7],[5,6],[5,7,6],[50],[7],[7,6],[15],[6],[100][5],[5,7],[5,6],[5,7,6],[50],[7],[7,6],[15],[6],[100] . There are 1010 of them. Hence, the array [5,50,7,15,6,100][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>=2 are [10],[100],[1000],[10000][10],[100],[1000],[10000] . There are 44 of them. Hence, the array [10,100,1000,10000][10,100,1000,10000] is valid.

首页