DWITE '08 R2 #3 - My drink is made of cubes

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
DWITE Online Computer Programming Contest, November 2008, Problem 3

In order to save on production cost, a company wants to find an optimal design for their new line of drink products. Given the volume of the contents, what is the minimum amount of material (surface area) needed to make a box? (This company is very cheap, and will sell their drinks in boxes).

An odd requirement is that the inside volume must be exact, and each side must be an integer value in length. (Note: that means that in some cases a box will use more material than a different box that could have held more volume.) (Also: it might help to think of contents as unit cubes, not liquid... but I already wrote the title).

The input will contain 5 lines, integers 1 \le N \le 65\,000 – target volume of the package.

The output will contain 5 lines, the surface area of the optimal box that fits the specifications.

Example calculation: for a volume of 27, the optimal box is a 3 \times 3 \times 3 cube; so the surface area will be 6 \text{ sides} \times (3 \times 3) = 54.

Again: if the volume is 15, then the optimal box is 5 \times 3 \times 1; so the surface area will be 46.

Final note: make sure your program runs fast, even for large volumes.

Sample Input

27
15
1
1000
64000

Sample Output

54
46
6
600
9600

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.