编程介的小学生 2017-02-16 02:37 采纳率: 20.5%
浏览 696
已采纳

Give me the result

Let me introduce an easy game to you: give you n integers in a line you must put (n-1) operators ("+","-","*" ,"/") between any two adjacent integers to combine them into a number(In the given order). At last the result mustn't have the digit k (0<=k<=9). You must find the largest result number that doesn't have the digit k.

Note:
(1) Mathematical operators work from left to right without any other regard for order of precedence. (i.e. 6 + 7 * 11 = 143)
(2) Every subtraction will produce a nonnegative result. So a - b actully means |a - b| (the absolute value). (i.e. 2 - 5 = 3)
(3) All divisions are integer divisions. (i.e 7 / 5 = 1). And of course the number zero cannot be a divisor.
Input

Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 200) which is the number of test cases. T consecutive test cases follow.
The first line of each test case is two numbers n and k (2<=n<=9,0<=k<=9). The second line of each test case is n nonnegative integers less than 100. Process to End Of File.

Output

For each test case output the largest result number that doesn't cotain the digit k. If there is no such number, output "No result" instead.
Sample Input

2
3 5
1 2 5
2 1
11 10
Sample Output

10
No result

  • 写回答

2条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题