eolymp
bolt
Try our new interface for solving problems
Problems

Cardboard Container

Cardboard Container

Fidget spinners 2017. A fidget cube is a cube with unit side lengths. You work in the planning department for a company that creates and ships fidget cubes. Having done some market analysis, you found that your customers want to receive shipments of exactly $v$ fidget cubes. This means you have to design a container that will hold exactly $v$ fidget cubes. Since fidget cubes are very fragile, you cannot have any empty space in your container. If there is empty space, they might move around, bump into each other and get damaged. Because of this, you decide to ship the fidget cubes in a rectangular cardboard box. The cost of a cardboard box is proportional to its surface area, costing exactly one unit of money per square unit of surface area. Of course you want to spend as little money as possible. Subject to the above constraints, how much money do you have to spend on a box for $v$ fidget cubes? \InputFile Contains a single integer $v~(1 \le v \le 10^6)$, the number of fidget cubes for which you need to build a box. \OutputFile Print the cost of the cheapest rectangular box as specified in the statement.
Time limit 1 second
Memory limit 128 MiB
Input example #1
1
Output example #1
6
Input example #2
4
Output example #2
16
Input example #3
3
Output example #3
14
Input example #4
5913
Output example #4
2790
Source 2018 Benelux Algorithm Programming Contest (BAPC), Problem C