-
[java]백준 소수 찾기 1978번알고리즘 문제풀이/백준(자바) 2023. 5. 1. 19:51
코드
import java.util.Scanner; public class BOJ_1978 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int q; int w=0; for (int i = 0; i < n; i++) { q = in.nextInt(); for (int j = 2; j <= q; j++) { if(j==q){ w++; } if (q%j==0) { break; } } } System.out.println(w); in.close(); } }
링크
https://www.acmicpc.net/problem/1978
'알고리즘 문제풀이 > 백준(자바)' 카테고리의 다른 글
[java]백준 단어의 개수 1152번 (0) 2023.05.03 [java]백준 몇개고? 27294번 (0) 2023.05.02 [java]백준 N번째 큰 수 2693번 (0) 2023.04.30 [java]백준 엄청난 부자2 1271번 (0) 2023.04.29 [java]백준 수 정렬하기 3 10989번 (0) 2023.04.28