From f056a28dfb1fde013f83525eff4566fe4d0783f5 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Fri, 7 Aug 2020 12:46:39 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=A8=EB=93=9C=EB=B0=94=ED=9D=90=20?= =?UTF-8?q?=EC=8B=9C=EB=A6=AC=EC=A6=88=206588,=209020,=2017103=20complete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zeta_python/9020.py | 6 ------ zeta_python/completed/17103.py | 27 +++++++++++++++++++++++++++ zeta_python/completed/6588.py | 26 ++++++++++++++++++++++++++ zeta_python/completed/9020.py | 26 ++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 6 deletions(-) delete mode 100644 zeta_python/9020.py create mode 100644 zeta_python/completed/17103.py create mode 100644 zeta_python/completed/6588.py create mode 100644 zeta_python/completed/9020.py diff --git a/zeta_python/9020.py b/zeta_python/9020.py deleted file mode 100644 index 68cde05..0000000 --- a/zeta_python/9020.py +++ /dev/null @@ -1,6 +0,0 @@ -N = int(input() -P = [] -last = 2 -for _ in range(N): - - # 골듭흐 파티션 diff --git a/zeta_python/completed/17103.py b/zeta_python/completed/17103.py new file mode 100644 index 0000000..2b51acc --- /dev/null +++ b/zeta_python/completed/17103.py @@ -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) diff --git a/zeta_python/completed/6588.py b/zeta_python/completed/6588.py new file mode 100644 index 0000000..51e2446 --- /dev/null +++ b/zeta_python/completed/6588.py @@ -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) diff --git a/zeta_python/completed/9020.py b/zeta_python/completed/9020.py new file mode 100644 index 0000000..3a3b873 --- /dev/null +++ b/zeta_python/completed/9020.py @@ -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