Home  >  Article  >  Backend Development  >  回想算法,非算法高手勿进

回想算法,非算法高手勿进

WBOY
WBOYOriginal
2016-06-13 11:38:30644browse

回溯算法,非算法高手勿进!

本帖最后由 xuzuning 于 2011-06-10 14:40:16 编辑 给定物品n件,他们的重量分别是w[0],w[1],……w[n-1],物品的价值分别为v[0],v[1],……v[n-1],另有一个背包,它可以容纳的总重量为w。设计一种物品挑选方案,要求从这n件物品中所选取的物品的总重量不超过背包的容量w,使选中物品的价值之和最大。

这个是很常见的背包回溯算法,谁能用php写一下!


注意:与算法无关的回复,将毫不留情的删去! 版主
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn