题目链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof/
题目如下:
class Solution {
public:
int cuttingRope(int n) {
if(n==2) return 1;
else if(n==3) return 2;
vector<int> dp(n+1);
dp[1]=1;
dp[2]=2;
dp[3]=3;
for(int i=4;i<=n;i++){
int maxval=0;
for(int j=1;j<=i/2;j++){
maxval=max(maxval,dp[j]*dp[i-j]);
}
dp[i]=maxval;
}
return dp[n];
}
};