n = [0, 1, 5, 11, 5] num = 4 # 物品数量 Vbag = 8 # 背包体积 dp = [[0] * (Vbag + 1) for _ in range(num+1)] ap = [[0] * (Vbag + 1)] * (num + 1) print(ap == dp) # weight = n # value = weight weight = [0, 2, 3, 4, 5] value = [0, 3, 4, 5, 6] for i in range(1, num + 1): for j in range(1, Vbag + 1): ...