找到Sum等于某事的可能组合 [英] Finding possible combination where Sum is equal to something

查看:64
本文介绍了找到Sum等于某事的可能组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个要求,我必须找到总和= 180的组合列表。

我有一组插入器只需要从这个数组中获取元素。



例如:

数组= {30,45, 60,15,60,30}

现在我作为输出应该得到 - 60,60,30,30或45,15,60,30,30或45,15,60,60



我正在尝试各种方法,但在一种或另一种情况下失败。



请提供输入。



谢谢

Hi,

I have a requirement where i have to find a list of combinations where the sum =180.
I have an array of intergers and have to pick up the elements from this array only.

For example :
Array = {30,45,60,15,60,30}
now i as an output should get - 60,60,30,30 or 45,15,60,30,30 or 45,15,60,60

I am trying various approaches but its failing in one or the other scenario.

Please provide inputs.

Thanks

推荐答案

它被称为子集和问题 [ ^ ]以下是您的解决方案:

找到组合的高效算法,其中总和等于已知数字,以一组数字 [ ^ ]

算法,用于查找大小为n的列表中的哪些数字总和为另一个数字 [ ^ ]

回溯 - 与C#的子集和 [ ^ ]

通过增加索引总和来生成排序组合的有效方法 [ ^ ]



祝你好运,

OI
It is called subset sum problem[^] and here are your solutions:
Efficient algorithm to find a combination, which summation is equal to a known number, in a set of number[^]
Algorithm to find which numbers from a list of size n sum to another number[^]
Backtracking – Subset sum with C#[^]
Efficient way to generate combinations ordered by increasing sum of indexes[^]

Good luck,
OI


参考这些链接

http://stackoverflow.com/questions/19437855/algorithm-for-finding-a-group-列表中的数字 - 等于目标 [ ^ ]



http:/ /stackoverflow.com/questions/10738926/efficient-a lgorithm-to-find-a-combination-summation-is-equal-a-known -n [ ^ ]
refer these links
http://stackoverflow.com/questions/19437855/algorithm-for-finding-a-group-of-numbers-in-a-list-that-equal-a-target[^]

http://stackoverflow.com/questions/10738926/efficient-algorithm-to-find-a-combination-which-summation-is-equal-to-a-known-n[^]


这篇关于找到Sum等于某事的可能组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆