Open hwangnk1004 opened 4 years ago
package main2;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int count = 0;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
count++;
}
}
if (count == 1) {
System.out.println(1 + " " + 1 + " " + n);
return;
}
long x = 0;
long y = 0;
long z = 0;
long sum2 = 0;
sum2 = 2000000000;
for (long i = 1; i*i*i <= n; i++) {
for (long j = 1; j*j <= n; j++) {
long k = n / (i * j);
if (i * j * k == n) {
long sum = i * j * 2 + j * k * 2 + i * k * 2;
if (sum2 > sum) {
sum2 = sum;
x = i;
y = j;
z = k;
}
}
}
}
if(x!=0){
System.out.println(x + " " + y + " " + z);
return;
}
long sum3=0;
for (long i = 1; i * i <= n; i++) {
if (i * i == n) {
sum3 = 1 * i * 2 + 1 * i * 2 + i * i * 2;
if (sum2 < sum3) {
System.out.println(x + " " + y + " " + z);
return;
} else {
System.out.println(1 + " " + i + " " + i);
return;
}
}
}
System.out.println(x + " " + y + " " + z);
}
}
문제 http://59.23.150.58/30stair/beer/beer.php?pname=beer
답
import java.util.Scanner;
public class Main { public static void main(String args[]) {
}