在给定的数字序列中找到k数的组合,以满足条件
我有这样的问题:
给定一个带有n
的数字列表(10< = n< = 60)
数字x1,x2,...,xn
这样1< = XJ< = 10
。输入数字k(1< = k< = 8)
,输入 数字m(0< = m< = 9)
。在给定的k数字中找到一个组合 数字列表,以使发现Modulo 10的k数量总和10 等于m。例如:对于序列n = {1,3,5,6,3,7,2,9,10,3,4,6}
在k = 3和m = 5的情况下,令人满意的组合之一是{5,6.4} - > (5 + 6 + 4)%10 = 5
。
我想找到解决问题的最佳解决方案,但是除了使用递归来蛮力外,我还没有找到其他方法。有比蛮力更好的方法吗? 谢谢您的阅读!
I have a problem like this:
Given a list of numbers with n
(10 <= n <= 60)
numbersx1, x2,..., xn
such that1 <= xj <= 10
. Enter the number k(1 <= k <= 8)
, enter the
number m(0 <= m <= 9)
. Find a combination of k numbers in the given
list of numbers such that the sum of the k numbers found modulo 10
equals m. For example: for the sequenceN = {1,3,5,6,3,7,2,9,10,3,4,6}
with k = 3 and m = 5, then one of the satisfying combinations is{5,6.4} -> (5 + 6 + 4) % 10 = 5
.
I want to find the optimal solution to the problem but i haven't found a way other than using recursion to brute-force. Is there a better way than brute-force?
Thank you for your reading!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论