-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNo_1978.java
More file actions
44 lines (37 loc) · 1.09 KB
/
No_1978.java
File metadata and controls
44 lines (37 loc) · 1.09 KB
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
43
44
/*
Problem_1978_소수 찾기
https://www.acmicpc.net/problem/1978
*/
import java.io.*;
import java.util.StringTokenizer;
public class No_1978 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st;
boolean isPrime;
int count = 0;
int one = -1;
int number = Integer.parseInt(br.readLine());
st = new StringTokenizer(br.readLine(), " ");
for (int i = 0; i < number; i++) {
one = Integer.parseInt(st.nextToken());
if (one == 1) {
continue;
}
isPrime = true;
for (int j = 2; j <= Math.sqrt(one); j++) {
if (one % j == 0) {
isPrime = false;
}
}
if (isPrime) {
count++;
}
}
br.close();
bw.write(count + "");
bw.flush();
bw.close();
}
}