ν°μ€ν 리 λ·°
728x90
λ°μν
λ¬Έμ
λ¬Έμ νμ΄
μ΄ λ¬Έμ λ μλ€μ ν© 2, λΆλΆν© λ¬Έμ μμ μμμ ν©μΌλ‘ λνλΌ μ μλ κ²½μ°μ μλ₯Ό μ°Ύλ λ¬Έμ μ΄λ€. μ°μν©μ ꡬνλ λ‘μ§μ μμ λ€λ£¬ 2 λ¬Έμ μ λμΌνλ©°, μμλ₯Ό ꡬνλ λΆλΆλ§ μΆκ°νλ©΄ μ½κ² ν μ μλ λ¬Έμ μ΄λ€.
μ½λ
from sys import stdin
def is_prime(num):
find = []
check = [True] * (num + 1)
check[1] = False
for i in range(2, num + 1):
if check[i]:
find.append(i)
for j in range(i * i, num + 1, i):
check[j] = False
return find
if __name__ == '__main__':
answer = start = end = 0
n = int(stdin.readline())
primes = is_prime(n)
subtotal = [0] * (n + 1)
for i in range(1, len(primes) + 1):
subtotal[i] = subtotal[i - 1] + primes[i - 1]
while True:
cur_subtotal = subtotal[end] - subtotal[start]
if cur_subtotal == n:
answer += 1
start += 1
elif cur_subtotal > n:
start += 1
elif end == len(primes):
break
else:
end += 1
print(answer)
728x90
λ°μν
'π¨βπ» μ½λ©ν μ€νΈ > λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
λ°±μ€: 1208 λΆλΆμμ΄μ ν© 2 (0) | 2020.08.16 |
---|---|
λ°±μ€: 1182 λΆλΆμμ΄μ ν© (0) | 2020.08.15 |
λ°±μ€: 1860 λΆλΆν© (0) | 2020.08.13 |
λ°±μ€: 2003 μλ€μ ν© 2 (0) | 2020.08.13 |
λ°±μ€: 2225 ν©λΆν΄ (0) | 2020.08.12 |
λκΈ
κΈ λ³΄κ΄ν¨
μ΅κ·Όμ μ¬λΌμ¨ κΈ
μ΅κ·Όμ λ¬λ¦° λκΈ