编程介的小学生 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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分