골드바흐 시리즈 6588, 9020, 17103 complete
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
N = int(input()
|
||||
P = []
|
||||
last = 2
|
||||
for _ in range(N):
|
||||
|
||||
# 골듭흐 파티션
|
||||
27
zeta_python/completed/17103.py
Normal file
27
zeta_python/completed/17103.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
T = int(sys.stdin.readline())
|
||||
|
||||
P = [2]
|
||||
K = [0] * 1000005
|
||||
K[2] = True
|
||||
for i in range(2, 1000000 - 1):
|
||||
for p in P:
|
||||
if i % p == 0:
|
||||
break
|
||||
elif p * p > i:
|
||||
P.append(i)
|
||||
K[i] = 1
|
||||
break
|
||||
else:
|
||||
P.append(i)
|
||||
K[i] = 1
|
||||
break
|
||||
for _ in range(T):
|
||||
n = int(sys.stdin.readline())
|
||||
c = 0
|
||||
for i in range(2, n//2+1):
|
||||
if K[i] and K[n - i]:
|
||||
c += 1
|
||||
i += 1
|
||||
print(c)
|
||||
26
zeta_python/completed/6588.py
Normal file
26
zeta_python/completed/6588.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import sys
|
||||
|
||||
P = [2]
|
||||
K = [False] * 1000005
|
||||
K[2] = True
|
||||
for i in range(2, 1000000 - 1):
|
||||
for p in P:
|
||||
if i % p == 0:
|
||||
break
|
||||
elif p * p > i:
|
||||
P.append(i)
|
||||
K[i] = True
|
||||
break
|
||||
else:
|
||||
P.append(i)
|
||||
K[i] = True
|
||||
break
|
||||
while True:
|
||||
n = int(sys.stdin.readline())
|
||||
if n == 0:
|
||||
break
|
||||
i = 2
|
||||
while not (K[i] and K[n - i]):
|
||||
i += 1
|
||||
else:
|
||||
print(n, "=", i, "+", n - i)
|
||||
26
zeta_python/completed/9020.py
Normal file
26
zeta_python/completed/9020.py
Normal file
@@ -0,0 +1,26 @@
|
||||
T = int(input())
|
||||
P = [2]
|
||||
K = [False, False, True] + [False for i in range(9999)]
|
||||
last = 2
|
||||
for _ in range(T):
|
||||
n = int(input())
|
||||
if n - 2 > last:
|
||||
for i in range(last, n - 1):
|
||||
for p in P:
|
||||
if i % p == 0:
|
||||
break
|
||||
elif p * p > i:
|
||||
P.append(i)
|
||||
K[i] = True
|
||||
break
|
||||
else:
|
||||
P.append(i)
|
||||
K[i] = True
|
||||
break
|
||||
i = 0
|
||||
while not (K[n//2 - i] and K[n//2 + i]):
|
||||
i += 1
|
||||
if n - 1 > last:
|
||||
last = n - 1
|
||||
print(n//2 - i, n//2 + i)
|
||||
# 골드바흐로 소수 여부를 False/True로 구별해 while 돌리는게 best
|
||||
Reference in New Issue
Block a user