def cuttingRope(n):
dp = [0]*(n+1)
dp[1] = 1
for i in range(2,n+1):
for j in range(1,i):
temp = max(dp[j],j)*max(i-j,dp[i-j])
dp[i] = max(dp[i],temp)
return dp[-1]
剪绳子
最新推荐文章于 2024-02-15 10:05:08 发布