ナップザック問題のブルートフォース実装を書く必要があります。ここでは擬似コードです: computeMaxProfit(weight_capacity)
max_profit = 0
S = {} // Each element of S is a weight-profit pair.
while true
if the sum of the weigh
私は、特定の方法でセットのパーティションを生成したいと思います。これらのパーティションを生成する過程でサイズNではないすべてのパーティションをフィルタリングする必要があります。一般的な解決策は "Generate all “unique” subsets of a set (not a powerset)"です。 [a,b,c]
[a,b]
[c]
[d,e,f]
[d,f]
[e]
文字列[]を入力として受け取り、EDIT1の下に示すように出力を与えるパワーセット関数を作成したいとします。私は機能上 EDIT1 としてこの機能を使用することはできません。この private static List<string> PowerSet(string[] input)
{
int n = input.Length;
// Power set contains