코드비교

Old VersionNew Version
1import java.util.Scanner; 1import java.util.*;
2public class Main { 2public class Main { 
3public static void main(String[] args) { 3public static int func(int n) {
4Scanner scn = new Scanner(System.in); 4for (int b = 2; b <= n; b++) {
5int T = scn.nextInt(); 5if ((n % b) == 0) {
6int[] arr = new int[T]; 6return b;
7for (int i = 0; i < T ; i++) {   
8arr[i] = scn.nextInt();   
9}   
10int[]factor=new int[99];   
11for(int i=0;i<T;i++) {   
12int div=2;   
13int n=0;   
14while (arr[i]>1) {   
15if (arr[i] % div == 0) {   
16factor[n] = div;   
17n++;   
18arr[i] = arr[i] / div;   
19} else {   
20div++;   
21} 7} 
22} 8} 
23if(factor[i]!=1) { 9return 1;
24for (int j = 0; j < factor.length; j++) { 10}
25if (factor[j] != 0) { 11public static void main(String[] args) {
26System.out.print(factor[j]); 12Scanner scan = new Scanner(System.in);
27if (factor[j + 1] != 0) { 13int test = scan.nextInt();
   14scan.nextLine();
   15int [] a = new int[test+1];
   16for(int i=0;i<test;i++) {
   17a[i] = scan.nextInt();
   18}
   19for(int i=0;i<test;i++) {
   20while (func(a[i]) != 1) {
   21System.out.print(func(a[i]));
   22a[i] /= func(a[i]);
   23if(func(a[i])!=1)
28System.out.print(" "); 24System.out.print(" "); 
29} 25} 
  26if(i!=(test-1) && func(a[i])==1) 
  27System.out.print("\n"); 
  28} 
  29scan.close(); 
30} 30} 
31} 31} 
32factor = new int[99];   
33System.out.println();   
34}   
35}   
36}   
37}   
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int T = scn.nextInt();
int[] arr = new int[T];
for (int i = 0; i < T ; i++) {
arr[i] = scn.nextInt();
}
int[]factor=new int[99];
for(int i=0;i<T;i++) {
int div=2;
int n=0;
while (arr[i]>1) {
if (arr[i] % div == 0) {
factor[n] = div;
n++;
arr[i] = arr[i] / div;
} else {
div++;
}
}
if(factor[i]!=1) {
for (int j = 0; j < factor.length; j++) {
if (factor[j] != 0) {
System.out.print(factor[j]);
if (factor[j + 1] != 0) {
System.out.print(" ");
}
}
}
factor = new int[99];
System.out.println();
}
}
}
}
import java.util.*;
public class Main {
public static int func(int n) {
for (int b = 2; b <= n; b++) {
if ((n % b) == 0) {
return b;
}
}
return 1;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int test = scan.nextInt();
scan.nextLine();
int [] a = new int[test+1];
for(int i=0;i<test;i++) {
a[i] = scan.nextInt();
}
for(int i=0;i<test;i++) {
while (func(a[i]) != 1) {
System.out.print(func(a[i]));
a[i] /= func(a[i]);
if(func(a[i])!=1)
System.out.print(" ");
}
if(i!=(test-1) && func(a[i])==1)
System.out.print("\n");
}
scan.close();
}
}