编程介的小学生 2017-01-04 07:04 采纳率: 20.5%
浏览 919
已采纳

Cheat

问题描述 :

In the summer of last year, Lemon, Yifenfei and CTW live in the same apartment. They usually played some game after they came back from lab. One day, Yifenfei came up with an idea about a new game. That game’s rules are as follows:
Yifenfei provides a positive integer n, Lemon and CTW should give 3 positive integers x, y and z in a limited time. The winner is who make the |n – x * y * z| as small as possible. If the value of |n – x * y * z| is tied, the rusult is determined by smaller x, then smaller y, then smaller z, until the winner appear. To make this game more diffcult, Yifenfei will also give a list of positive integers, x, y and z cannot be included in this list.
Because Lemon is so smart, CTW never win even one game. Can you provides CTW a program to help him to get the optimum answer?
输入:

Input includes several cases. The first line of a case contains two integers t, n. Then follows t positive integers in the seconde line.Input ends with a case t = 0 and n = 0. 0 <= t <= 50, 0 < n <= 1000.
输出:

Input includes several cases. The first line of a case contains two integers t, n. Then follows t positive integers in the seconde line.Input ends with a case t = 0 and n = 0. 0 <= t <= 50, 0 < n <= 1000.
样例输入:

1 1
1
2 10
1 2
0 0
样例输出:

2 2 2
3 3 3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-01-11 16:44
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器