-
[백준] 1978번_소수찾기Study/알고리즘 2020. 2. 8. 13:45
문제 링크 : https://www.acmicpc.net/problem/1978
1978번: 소수 찾기
첫 줄에 수의 개수 N이 주어진다. N은 100이하이다. 다음으로 N개의 수가 주어지는데 수는 1,000 이하의 자연수이다.
www.acmicpc.net
def isPrime(p): if p == 1: return 0 else: for i in range(2,int(p**0.5)+1): if p%i==0: return 0 return 1 n = int(input()) arr = list(map(int,input().split())) cnt = 0 for i in range(n): cnt += isPrime(arr[i]) print(cnt)
'Study > 알고리즘' 카테고리의 다른 글
[백준] 4948번_베르트랑공준 (0) 2020.02.10 [백준] 1929번_소수구하기 (0) 2020.02.09 [백준] 2775번_부녀회장이될테야 (0) 2020.02.07 [백준] 10250번_ACM호텔 (0) 2020.02.06 [백준] 2839번_설탕배달 (0) 2020.02.06