编程介的小学生 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 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛