728x90
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i, j, s, cnt = 0;
int n = sc.nextInt();
int a[] = new int[n];
for( i = 0; i < n; i++ )
a[i] = sc.nextInt();
loop:
for( i = 0; i < n; i++ ) {
if( a[i] < 2 ) continue;
s = (int)Math.sqrt( a[i] );
for( j = 2; j <= s; j++ )
if( a[i] % j == 0 )
continue loop;
cnt++;
}
System.out.println(cnt);
sc.close();
}
}
소수 : 자신보다 작은 두 개의 자연수를 곱하여 만들 수 없는 1보다 큰 자연수
( 약수가 1과 자기 자신뿐인 1보다 큰 자연수 )
반응형
'코딩 문제 풀기 ( Algorithm problem solving ) > 백준 온라인 저지 ( BOJ )' 카테고리의 다른 글
[백준(Baekjoon)][자바(java)] (1929) 소수 구하기 / 수학 2 (0) | 2020.03.10 |
---|---|
[백준(Baekjoon)][자바(java)] (2581) 소수 / 수학 2 (0) | 2020.03.10 |
[백준(Baekjoon)][자바(java)] (1011) Fly me to the Alpha Centauri / 수학 1 (0) | 2020.03.10 |
[백준(Baekjoon)][자바(java)] (2775) 부녀회장이 될테야 / 수학 1 (0) | 2020.03.08 |
[백준(Baekjoon)][자바(java)] (10250) ACM 호텔 / 수학 1 (0) | 2020.03.08 |