整数拆分⚓︎ Leetcode题目链接 描述⚓︎ 详见中文题目链接。 解答⚓︎ 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public: int integerBreak(int n) { vector<int> dp(n + 1); dp[2] = 1; for (int i = 3; i <= n; i++) { for (int j = 1; j <= i / 2; j++) dp[i] = max(dp[i], max((i - j) * j, dp[i - j] * j)); } return dp[n]; } };