Minimum Cost to Split into Ones
You are given an integer n.
In one operation, you may split an integer x into two positive integers a and b such that a + b = x.
The cost of this operation is a * b.
Return an integer denoting the minimum total cost required to split the integer n into n ones.
Example 1
Input
n = 3Output
3One optimal sequence costs 2 to split 3 into 1 and 2, then costs 1 to split 2 into 1 and 1, for a total cost of 3.
Example 2
Input
n = 4Output
6One optimal sequence costs 4 to split 4 into 2 and 2, then costs 1 for each 2 split into 1 and 1, for a total cost of 6.
Constraints
- 1 <= n <= 500