Easy Java DP solution with explanation, typical knapsack problem
\n\n        int[] dp = new int[n + 1];\n        dp[0] = 1;\n        int max = 0;\n        for(int i = 1; i < n; i++){\n            for(int j = i; j <= n; j++){\
\n```\n        int[] dp = new int[n + 1];\n        dp[0] = 1;\n        int max = 0;\n        for(int i = 1; i < n; i++){\n            for(int j = i; j <= n; j++){\n                dp[j] = Math.max(dp[j], dp[j - i] * i);\n                if(j == n){\n                    if(max < dp[j])\n                        max = dp[j];\n                }\n            }\n        }\n        return max;\n```\nThis is a typical knapsack problem. We can assume that the volume of the knapsack is **n**. The items we can choose range from **1** to **n - 1**(because we must divide n into at least two positive parts). The point is that we can choose each item many times. \nThe first loop means the items we can choose(**i** means first i items).\nAnd in the second loop, **j** means the sum of items that we are going to choose.\nFor each item, we have two choices, pick it up or not. And we should choose the max result.\njust as ***dp[j] = Math.max(dp[j], dp[j - i] * i);***\nThen, you are able to solve the problem.\nBy the way, the initialization is also important.
[]