题解 | #剪绳子#
剪绳子
https://www.nowcoder.com/practice/57d85990ba5b440ab888fc72b0751bf8
class Solution {
public:
int cutRope(int number) {
vector<int> dp(number+1, 0);
dp[1]=1;
for(int i = 2; i <= number; i++)
for(int j = 1; j < i; j++)
dp[i]=max(dp[i],max(dp[i-j]*j,j*(i-j)));
return dp[number];
}
};