반응형
https://www.acmicpc.net/problem/2581
import math
def isPrime(num):
if num == 1:
return False
n = int(math.sqrt(num))
for i in range(2,n+1):
if num%i==0:
return False
return True
M = int(input())
N = int(input())
ls=[]
for i in range(M,N+1):
if isPrime(i):
ls.append(i)
if len(ls) == 0:
print(-1)
else:
print(sum(ls))
print(min(ls))
반응형
'백준 문제풀이' 카테고리의 다른 글
baekjoon - python - 10171 (0) | 2020.09.02 |
---|---|
baekjoon - python - 4948 (0) | 2020.09.02 |
baekjoon - python - 1978 (0) | 2020.08.29 |
baekjoon - python - 10039 (0) | 2020.08.29 |
baekjoon - python - 1929 (0) | 2020.08.28 |
댓글