You want to ship N cubes abroad. The size of each cube is 1 x 1 x 1. You can only ship the cubes by filling them into a single cuboid box. The cost of shipping a cuboid box with dimensions a x b x c is equal to (a+b+c).
You can't leave any empty space in the box, because the cubes would shift and get damaged during the transfer.
You are given an int N. Return the minimal cost of shipping N cubes.
提示:
1
Returns: 3
The only way is to use a box with dimensions 1 x 1 x 1.
6
Returns: 6
This time one optimal solution is to send a box with dimensions 1 x 2 x 3. The cost of sending this box is 1+2+3 = 6. Any other option is at least as expensive as this one. For example, sending a box with dimensions 6 x 1 x 1 has the cost 6+1+1 = 8.