#3857

Minimum Cost to Split into Ones

medium · 83.2% accepted · 44 likes · top 95%

Description

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.

Solution