原来这贴跑到这儿来了,还得我好找,偶一般知在算法版闲逛。
to KingSunSha(弱水三千):
你的思路是正确的,不过用回溯的方法求解却不是一种好办法。正如偶在前面所说的,我觉得用分枝定界法可以大大提高求解的效率。分枝定界法可以参考: http://202.113.96.10/ini/arithetics/No55.htm
Backpack is a classic NP problem, which means the complexity of finding the best solution is at least O(N*N). When N gets bigger, theoretically there is no way to solve the problem within an accepable time. Not mention that here we want to extend the problem into 3 dimensions (It's still NP, though).
On the other hand, there are always many heuristic algorithms which may give some acceptable results (may or may not be the best) in a reasonable time.
sound like you are looking for a backpack algorithm, search on google.com:
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=backpack+algorithm&btnG=Google+Search
A Fast and Efficient Solution to the Backpack Problem
http://www.edm2.com/0601/backpack.html