编程介的小学生 2017-03-14 08:46 采纳率: 20.5%
浏览 839
已采纳

Best Balance

FatMouse has just got a baby! In order to control the baby's mouse weight, he bought a balance as well as some weights. By placing his baby on one side of the balance and some of the weights on the other, he could read how heavy his baby is. However, the baby is catching on weight so fast that FatMouse worries he would not be able to do that one day. Thus he has decided to purchase several other weights. He can choose how heavy these weights are. And of course he wants to maximize the smallest weight that this balance can not measure.
All weights are integers (in pounds). The balance can detect and compensate any fractional weight (less than one pound) difference between two sides. FatMouse never places any weight on the same side of his baby.

Input Description

Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 50) which is the number of test cases. T test cases follow, each preceded by a single blank line.

Each case starts with two integers n (0 <= n <= 20) and k (0 <= k <= 10), where n is the number of the weights that FatMouse currently has, and k is the number of weights that FatMouse is going to purchase. The next n integers ci (0 <= i < n, 1 <= ci < 100,000) give the weights (in pounds) he currently owns. Two consecutive numbers are separated by a single space.

Output Description

Results should be directed to standard output. Start each case with "Case #:" on a single line, where # is the case number starting from 1. Two consecutive cases should be separated by a single blank line. No blank line should be produced after the last test case.

The output of each test case should be a single integer, which is the maximized smallest weight that he will not be able to measure.

Sample Input

4

3 1 1 2 4

3 2 1 3 5

2 1 1 1

3 0 1 2 5

Sample Output

Case 1:
16

Case 2:
24

Case 3:
6

Case 4:
4

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-26 14:41
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥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,如何解決?