编程介的小学生 2017-09-17 13:48 采纳率: 20.5%
浏览 1046
已采纳

Need for Pipes

Suppose that you need to buy some pipes because you have to build a long pipe using the pipes. Wired enough, you find that in the shop, all of the pipes with different lengths have the same price. You have limited money and limited material with which you can connect the pipes. Your task is to buy the appropriate pipes with which you can build a longer pipe with all kinds of lengths from 1 to N so that N is maximal.

Note:
1. the lengths are integers;
2. every pipe is worthy of 100 yuans, and the money you have is between 0-700;
3. the material needed to connect the pipe is limited. The number of pipes you can connect is between 0 and 5;
4. once a kind of pipe with a certain length is bought, you can get as many pipes of that length as you wish.

For example: if we have 590 yuan and the material can mostly connect 4 pipes ,then we can buy 5 pipes. If we buy the pipes of lengths 1, 3, 11, 15, and 32, we will be able to make pipes with lengths 1, 2, 3, 4, ..., 70 where 70 is the maxmum length we can get.

Input

In the first line of input there is a single N (< 50) denoting the number of cases. Each case occupies one line which contains two numbers m and n expressing the maximum number of pipes we can connect and the money we have.

Output

For each test case, output the maxmial length we can get in the first line and the lengths of pipes you should buy in the second line.
If there are several possibilities, output the smaller sequence. For example, sequence (1,3,4) is considered smaller than sequence (1,4,5) so you should output 1 3 4. If the task is impossible, just output "sorry".

Sample Input

2

4 500

2 0

Sample Output

70
1 3 11 15 32
sorry

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-02 00:51
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?