311257: CF1957B. A BIT of a Construction

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. A BIT of a Constructiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Given integers $n$ and $k$, construct a sequence of $n$ non-negative (i.e. $\geq 0$) integers $a_1, a_2, \ldots, a_n$ such that

  1. $\sum\limits_{i = 1}^n a_i = k$
  2. The number of $1$s in the binary representation of $a_1 | a_2 | \ldots | a_n$ is maximized, where $|$ denotes the bitwise OR operation.
Input

The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The only line of each test case contains two integers $n$ and $k$ ($1 \leq n \leq 2 \cdot 10^5$, $1 \leq k \leq 10^9$) — the number of non-negative integers to be printed and the sum respectively.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

Output

For each test case, output a sequence $a_1, a_2, \ldots, a_n$ on a new line that satisfies the conditions given above.

If there are multiple solutions, print any of them.

ExampleInput
4
1 5
2 3
2 5
6 51
Output
5
1 2
5 0
3 1 1 32 2 12
Note

In the first test case, we have to print exactly one integer, hence we can only output $5$ as the answer.

In the second test case, we output $1, 2$ which sum up to $3$, and $1 | 2 = (11)_2$ has two $1$s in its binary representation, which is the maximum we can achieve in these constraints.

In the fourth test case, we output $3, 1, 1, 32, 2, 12$ which sum up to $51$, and $3 | 1 | 1 | 32 | 2 | 12 = (101\,111)_2$ has five $1$s in its binary representation, which is the maximum we can achieve in these constraints.

Output

题目大意:
给定整数n和k,构造一个由n个非负整数组成的序列a_1, a_2, ..., a_n,使得:

1. a_1 + a_2 + ... + a_n = k
2. 在a_1 | a_2 | ... | a_n的二进制表示中1的数量最大化,其中"|"表示按位或操作。

输入数据格式:
第一行包含一个整数t(1 ≤ t ≤ 10^4)——测试用例的数量。
每个测试用例仅包含一行,有两个整数n和k(1 ≤ n ≤ 2 * 10^5,1 ≤ k ≤ 10^9)——要打印的非负整数的数量和它们的和。
保证所有测试用例的n之和不超过2 * 10^5。

输出数据格式:
对于每个测试用例,输出一个满足上述条件的新行上的序列a_1, a_2, ..., a_n。
如果有多个解,打印其中任何一个。题目大意: 给定整数n和k,构造一个由n个非负整数组成的序列a_1, a_2, ..., a_n,使得: 1. a_1 + a_2 + ... + a_n = k 2. 在a_1 | a_2 | ... | a_n的二进制表示中1的数量最大化,其中"|"表示按位或操作。 输入数据格式: 第一行包含一个整数t(1 ≤ t ≤ 10^4)——测试用例的数量。 每个测试用例仅包含一行,有两个整数n和k(1 ≤ n ≤ 2 * 10^5,1 ≤ k ≤ 10^9)——要打印的非负整数的数量和它们的和。 保证所有测试用例的n之和不超过2 * 10^5。 输出数据格式: 对于每个测试用例,输出一个满足上述条件的新行上的序列a_1, a_2, ..., a_n。 如果有多个解,打印其中任何一个。

加入题单

上一题 下一题 算法标签: