CF960C.Subsequence Counting
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
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 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 1018.
Note the number of elements in the output array should not be more than 104. If no answer is possible, print - 1.
皮卡丘有一个数组。他将该数组的所有非空子序列都写在了纸上。注意,一个大小为 n 的数组共有 2n−1 个非空子序列。
皮卡丘一如既往地调皮,他删去了所有满足“子序列中最大元素 − 子序列中最小元素 ≥d”的子序列。
最终,皮卡丘剩下 X 个子序列。
然而,他弄丢了最初的数组,现在陷入了严重困境。他只记得数字 X 和 d。现在他希望你构造出任意一个满足上述条件的数组。输出数组中的所有数都必须是小于 1018 的正整数。
注意:输出数组的元素个数不得超过 104。若不存在满足条件的数组,请输出 −1。
输入格式
The only line of input consists of two space separated integers X and d (1 ≤ X, d ≤ 109).
输入仅包含一行,由两个以空格分隔的整数 X 和 d 组成(1 ≤ X, d ≤ 109)。
输出格式
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 < 1018).
If there is no answer, print a single integer -1. If there are multiple answers, print any of them.
输出应包含两行。
第一行应包含一个整数 n(1 ≤ n ≤ 10000)—— 表示最终数组中整数的个数。
第二行应包含 n 个以空格分隔的整数 —— a1,a2,...,an(1 ≤ ai < 1018)。
若不存在满足条件的答案,则输出单个整数 −1。若存在多个答案,输出任意一个即可。
输入输出样例
输入#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 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.
在第一个样例的输出中,移除所有满足“子序列的最大元素 − 子序列的最小元素 ≥5”的子序列后,剩余的子序列为:
[5], [5, 7], [5, 6], [5, 7, 6], [50], [7], [7, 6], [15], [6], [100]
共 10 个。因此,数组 [5, 50, 7, 15, 6, 100] 是合法的。
类似地,在第二个样例的输出中,移除所有满足“子序列的最大元素 − 子序列的最小元素 ≥2”的子序列后,剩余的子序列为:
[10], [100], [1000], [10000]
共 4 个。因此,数组 [10, 100, 1000, 10000] 是合法的。
输入解题思路,AI测评打分。不知道怎么写?