๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
S2 | ์๋ผํ ์คํ ๋ค์ค์ ์ฒด
- ์๋ผํ ์คํ ๋ค์ค์ ์ฒด๋ฅผ ์ฌ์ฉํ์ฌ ์์๋ฅผ ๊ตฌํ๊ณ ์์.
์ฃผ์ด์ง ๊ตฌ๊ฐ์ ๋ง๊ฒ ์์์ ๊ฐ์๋ฅผ ๊บผ๋
๐ป์์ค ์ฝ๋
import sys
def eratos(n):
for j in range(n * 2, 123456 * 2 + 1, n):
dp[j] = 0
dp = [1] * (123456 * 2 + 1)
dp[0], dp[1] = 0, 0
for i in range(2, 123456 * 2 + 1):
if dp[i] == 1:
eratos(i)
input = sys.stdin.readline
while True:
N = int(input())
if N == 0: # ์
๋ ฅ ๋ง์ง๋ง
break
print(sum((dp[N + 1:N * 2 + 1])))
๐๋ฌธ์ ํ์ธ
์ถ์ฒ: BACKJOON ONLINE JUDGE
๋งํฌ: https://www.acmicpc.net/problem/4948
๋ฐ์ํ
'Algorithm Problem > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] ๋ฐฑ์ค - 11722. ๊ฐ์ฅ ๊ธด ๊ฐ์ํ๋ ๋ถ๋ถ ์์ด (0) | 2020.10.03 |
---|---|
[python] ๋ฐฑ์ค - 7562. ๋์ดํธ์ ์ด๋ (0) | 2020.10.02 |
[python] ๋ฐฑ์ค - 16234. ์ธ๊ตฌ ์ด๋(์ผ์ฑ SW ์ญ๋ ํ ์คํธ ๊ธฐ์ถ ๋ฌธ์ ) (2) | 2020.09.30 |
[python] ๋ฐฑ์ค - 1931. ํ์์ค ๋ฐฐ์ (0) | 2020.09.29 |
[python] ๋ฐฑ์ค - 1929. ์์ ๊ตฌํ๊ธฐ (0) | 2020.09.28 |