문제

https://www.acmicpc.net/problem/1978


문제 풀이

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
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int answer = 0;

        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int cnt = 0;
            int m = sc.nextInt();
            for (int j = 1; j <= m; j++) {
                if (m % j == 0) {
                    cnt++;
                }
            }
            if (cnt == 2) {
                answer += 1;
            }
        }

        System.out.println(answer);
    }
}

카테고리:

업데이트:

댓글남기기