Integer Break

 1 class Solution {
 2 public:
 3     int integerBreak(int n) {
 4         vector<int> res(n+1,0);
 5         res[1]=1;
 6         res[2]=1;
 7         for(int i=3; i<=n; i++)
 8         {
 9             for(int j=1; j<i; j++)
10             res[i] = max(j*res[i-j],max(res[i],j*(i-j)));
11         }
12         return res[n];
13     }
14 };
原文地址:https://www.cnblogs.com/daocaorenblog/p/5579669.html