2^a, 3^b, 5^c, 7^d, 11^e
쫘라락 출력
if문 쭉 안 돌리는게 있어보이긴 하네,,,
import java.util.Scanner;
import java.util.StringTokenizer;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for ( int i = 1; i <= t; i++){
int n = sc.nextInt();
int a=0, b=0, c=0, d=0, e=0;
while (n != 1){
if(n%2==0){
n /= 2;
a++;
}
if(n%3==0){
n /= 3;
b++;
}
if(n%5==0){
n /= 5;
c++;
}
if(n%7==0){
n /= 7;
d++;
}
if(n%11==0){
n /= 11;
e++;
}
}
System.out.println("#"+i+" "+a+" "+b+" "+c+" "+d+" "+e);
}
}
}
import java.util.Scanner;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner (System.in);
int T; //테스트 케이스 개수
T=sc.nextInt();
String answer = "";
for(int test_case = 1; test_case <= T; test_case++) //테스트케이스만큼 반복
{
int N = sc.nextInt();
int[] result = new int[5];
int[] num = {2,3,5,7,11};
for ( int i=0; i<result.length; i++)
{
int temp=0;
while(N%num[i]==0) {
N=N/num[i];
temp++;
}
result[i]=temp;
}
answer+= "#" + test_case + " ";
for(int i=0; i<result.length; i++)
{
answer += result[i]+" ";
}
answer += "\n";
}
System.out.println(answer);
}
}