小编Ste*_*ang的帖子

定量背包0-1

我正在编写具有多个约束的背包 0-1 的变体。除了重量约束之外,我还有数量约束,但在本例中,我想解决背包问题,因为我的背包中需要恰好有 n 件物品,且重量小于或等于 W。目前正在为简单的 0-1 案例实现一个动态编程 ruby​​ 解决方案,基于http://rosettacode.org/wiki/Knapsack_problem/0-1#Ruby上 Rosetta Code 的代码。

实施固定数量限制的最佳方式是什么?

algorithm knapsack-problem dynamic-programming

4
推荐指数
1
解决办法
2752
查看次数