311218: CF1951D. Buying Jewels

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

Description

D. Buying Jewelstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNightwish feat. Jonsu - Erämaan Viimeinen

Alice has $n$ coins and wants to shop at Bob's jewelry store. Today, although Bob has not set up the store yet, Bob wants to make sure Alice will buy exactly $k$ jewels. To set up the store, Bob can erect at most $60$ stalls (each containing an unlimited amount of jewels) and set the price per jewel for each stall to be an integer number of coins between $1$ and $10^{18}$.

Fortunately, Bob knows that Alice buys greedily: and she will go to stall $1$, buy as many jewels as possible, then go to stall $2$, buy as many jewels as possible, and so on until the last stall. Knowing this, Bob can choose the number of stalls to set up, as well as set the price for each stall so that Alice buys exactly $k$ jewels. Help Bob fulfill the task, or determine if it is impossible to do so.

Note that Alice does not need to spend all her coins.

Input

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

Each test case contains two positive integers $n$ and $k$ ($1 \le n, k \le 10^{18}$) — the number of coins Alice has and the number of jewels Bob wants Alice to have bought at the end.

Output

For each test case, print on one line "YES" if Bob can erect at most $60$ stalls and set the prices for the stalls such that Alice buys exactly $k$ jewels, or "NO" if it is impossible to do so.

If the answer is "YES", on the second line, print an integer $s$ ($1 \le s \le 60$) — the number of stalls to be set up by Bob. On the third line, print $s$ positive integers $p_1, p_2, \ldots, p_s$ ($1 \le p_i \le 10^{18})$ that represent such a satisfactory pricing $p$, where $p_i$ is the price per jewel for stall $i$. If there are multiple such $p$'s, print any of them.

ExampleInput
3
7 3
6 4
255 8
Output
YES
10
2 3 4 5 6 7 8 9 10 11
NO
YES
8
128 64 32 16 8 4 2 1
Note

In the first test case, at the first stall, Alice buys $3$ jewels and is left with $1$ coin. This is not enough to buy any jewels for any of the remaining stalls, so Alice buys exactly $3$ jewels at the end.

In the third test case,

  • At the first stall, Alice buys $1$ jewel and is left with $127$ coins.
  • At the second stall, Alice buys $1$ jewel and is left with $63$ coins.
  • At the third stall, Alice buys $1$ jewel and is left with $31$ coins.
  • At the fourth stall, Alice buys $1$ jewel and is left with $15$ coins.
  • At the fifth stall, Alice buys $1$ jewel and is left with $7$ coins.
  • At the sixth stall, Alice buys $1$ jewel and is left with $3$ coins.
  • At the seventh stall, Alice buys $1$ jewel and is left with $1$ coin.
  • At the eighth stall, Alice buys $1$ jewel and is left with $0$ coins.
Therefore, Alice buys exactly $8$ jewels in total.

Output

题目大意:
爱丽丝有n个硬币,想在鲍勃的珠宝店购物。尽管鲍勃还没有准备好店铺,但他想确保爱丽丝能买到恰好k个珠宝。鲍勃最多可以设置60个摊位(每个摊位可以提供无限数量的珠宝),并且每个摊位的珠宝价格可以是1到10^18之间的整数个硬币。爱丽丝会贪婪地购买珠宝,她会先在第一个摊位买尽可能多的珠宝,然后是第二个摊位,以此类推,直到最后一个摊位。请帮助鲍勃确定是否可以设置摊位的数量以及每个摊位的价格,使爱丽丝恰好买到k个珠宝。如果不能,则输出不可能。

输入数据格式:
每个测试包含多个测试用例。第一行包含一个整数t(1≤t≤1000)——测试用例的数量。接下来是t个测试用例的描述。
每个测试用例包含两个正整数n和k(1≤n, k≤10^18)——爱丽丝拥有的硬币数量和鲍勃希望爱丽丝最终购买的珠宝数量。

输出数据格式:
对于每个测试用例,如果鲍勃可以设置最多60个摊位并设置摊位价格,使得爱丽丝恰好买到k个珠宝,则在一行中打印"YES";如果不可能,则打印"NO"。
如果答案为"YES",在第二行打印一个整数s(1≤s≤60)——鲍勃需要设置的摊位数。在第三行,打印s个正整数p_1, p_2, ..., p_s(1≤p_i≤10^18),代表一种满意的价格p,其中p_i是第i个摊位的珠宝价格。如果有多个这样的p,可以打印其中任何一个。题目大意: 爱丽丝有n个硬币,想在鲍勃的珠宝店购物。尽管鲍勃还没有准备好店铺,但他想确保爱丽丝能买到恰好k个珠宝。鲍勃最多可以设置60个摊位(每个摊位可以提供无限数量的珠宝),并且每个摊位的珠宝价格可以是1到10^18之间的整数个硬币。爱丽丝会贪婪地购买珠宝,她会先在第一个摊位买尽可能多的珠宝,然后是第二个摊位,以此类推,直到最后一个摊位。请帮助鲍勃确定是否可以设置摊位的数量以及每个摊位的价格,使爱丽丝恰好买到k个珠宝。如果不能,则输出不可能。 输入数据格式: 每个测试包含多个测试用例。第一行包含一个整数t(1≤t≤1000)——测试用例的数量。接下来是t个测试用例的描述。 每个测试用例包含两个正整数n和k(1≤n, k≤10^18)——爱丽丝拥有的硬币数量和鲍勃希望爱丽丝最终购买的珠宝数量。 输出数据格式: 对于每个测试用例,如果鲍勃可以设置最多60个摊位并设置摊位价格,使得爱丽丝恰好买到k个珠宝,则在一行中打印"YES";如果不可能,则打印"NO"。 如果答案为"YES",在第二行打印一个整数s(1≤s≤60)——鲍勃需要设置的摊位数。在第三行,打印s个正整数p_1, p_2, ..., p_s(1≤p_i≤10^18),代表一种满意的价格p,其中p_i是第i个摊位的珠宝价格。如果有多个这样的p,可以打印其中任何一个。

加入题单

上一题 下一题 算法标签: