2013
11-12

Beer Refrigerator

Beer Lovers Club makes regular parties. They hate warm beer, but club’s refrigerator is too small to store enough beer for the whole company. So they decided to order a special super-big beer refrigerator. The new refrigerator should be a parallelepiped a × b × c and store exactly n cubical 1 × 1 × 1 beer boxes (the club has n members). To decrease losses of cold, the total area of the surface of the refrigerator must be as small as possible.

For example, if the capacity of the refrigerator must be 12, the possible variants are:

 Dimensions Surface Area 3 × 2 × 2 32 4 × 3 × 1 38 6 × 2 × 1 40 12 × 1 × 1 50

The best variant in this case is 3 × 2 × 2.

Help the beer lovers to find the optimal dimensions of their new refrigerator.

The input file contains single integer number n (1 ≤ n ≤ 106) — the capacity of the refrigerator. Help the beer lovers to find the optimal dimensions of their new refrigerator.

Output three integer numbers: a, b and c — the optimal dimensions of the refrigerator. If there are several solutions, output any of them.

#112#213#31000000

#13 2 2#21 13 1#3100 100 100

//* @author: [email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
while(in.hasNext())
{
int a=in.nextInt();
int x=1,y=1,z=a,m=1,n=1,q=a;
for(int i=(int)Math.pow(a,1.0/3)+1;i>0;i--)
{
if(a%i==0)
{
x=i;
for(int j=(int)Math.sqrt(a/x)+1;j>0;j--)
{
if((a/x)%j==0)
{
y=j;
z=a/x/j;
if(x*y+y*z+z*x< m*n+n*q+q*m)
{
m=x;
n=y;
q=z;
}
break;
}
}
}
}
System.out.println(m+" "+n+" "+q);
}
}
}

1. Often We don’t set up on weblogs, but I would like to condition that this established up really forced me individually to do this! considerably outstanding publish