Problem solving:
Use dp [i] to store the maximum product of the rope at length i, which is related to the previous maximum product of 0 ~ i-1
class Solution {
public:
//vector<int> arr;
int cuttingRope(int n) {
vector<int> dp(n+1,0);
dp[1]=1;
for(int i=2;i<=n;i++){
for(int j=i-1;j>=1;j--)
dp[i]=max(dp[i],max(j,dp[j])*(i-j));
}
return dp[n];
}
};