CutPrices=[(1,5),(2,6),(3,2)]
CutPrices=sorted(CutPrices)
RodLength=int(input("Enter Rod Length =>"))
def CutRod(p, n):
if n == 0:
return 0
q =float(-inf)
for i in range(1,n+1):
q = max(q, p[i-1][1] + CutRod(p, n-p[i-1][0])
return q
print(CutRod(CutPrices,RodLength))
答案 0 :(得分:0)
你在这一行上缺少右括号:
q = max(q, p[i-1][1] + CutRod(p, n-p[i-1][0]))
^