动态规划 beat100%
memo[i]=max(j*(i-j),max(j*memo[i-j],memo[i]))
class Solution {
public:
int integerBreak(int n) {
if(n<1) return 0;
vector<int> memo(n+1,-1);
memo[1]=1;
for(int i=2;i<=n;i++){
for(int j=1;j<=i-1;j++){
memo[i]=max3(j*(i-j),j*memo[i-j],memo[i]);
}
}
return memo[n];
}
int max3(int a,int b,int c){
return max(a,max(b,c));
}
};