标签:
from __future__ import division
weight = [10,20,30]
volume =[60,100,120]
kept = [0,0,0]
M = 50
def knapback(M, weight, volume, kept):
for i in range(0,3):
if weight[i] < M:
kept[i] = 1
M = M-weight[i]
else:
kept[i] = M/weight[i]
knapback(M, weight, volume, kept)
print kept
标签:
原文地址:http://www.cnblogs.com/zhaodonglin/p/5565781.html