Java/SW Expert Academy
1945. 간단한 소인수분해
GLOWWW
2021. 1. 11. 19:22
package oSWExpertAcademy;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class D2_1945 {
public static void main(String[]args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
int testCount = Integer.parseInt(br.readLine());
for(int tc=1; tc<=testCount; tc++) {
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int input = Integer.parseInt(br.readLine());
while(input%2 == 0) {
input /= 2;
a++;
}
while(input%3 == 0) {
input /= 3;
b++;
}
while(input%5 == 0) {
input /= 5;
c++;
}
while(input%7 == 0) {
input /= 7;
d++;
}
while(input%11 == 0) {
input /= 11;
e++;
}
System.out.println("#"+tc+" "+a+" "+b+" "+c+" "+d+" "+e);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}