-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_11653.java
More file actions
42 lines (38 loc) ยท 930 Bytes
/
_11653.java
File metadata and controls
42 lines (38 loc) ยท 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package backjoon;
// https://www.acmicpc.net/problem/11653
// ์์ธ์๋ถํด
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class _11653 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
//sol memory 11556 runtime 100
List<Integer> primeNum = new ArrayList<>();
for(int i=2; i<= Math.sqrt(N); i++){
// ์ฝ์์ผ๋
while (N % i == 0) {
sb.append(i).append('\n');
N /= i;
}
}
// Math.sqrt(N)์๋ ์๊ธฐ ์์ ์ด ์ฝ์์ผ๋๊ฐ ํฌํจ์ด ์๋๋ฏ๋ก ๋ฐ๋ก ํฌํจํด์ค๋ค
if (N != 1) {
sb.append(N);
}
System.out.println(sb);
}
}
/*
input 72
output
2
2
2
3
3
*/