From 3459d91bd50f4b21c30608415bcdca1020f80c69 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Mon, 3 Nov 2025 22:48:17 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Solved:=202960=20=EC=97=90=EB=9D=BC?= =?UTF-8?q?=ED=86=A0=EC=8A=A4=ED=85=8C=EB=84=A4=EC=8A=A4=EC=9D=98=20?= =?UTF-8?q?=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\212\244\354\235\230_\354\262\264.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "INSEA-99/week08/2960_\354\227\220\353\235\274\355\206\240\354\212\244\355\205\214\353\204\244\354\212\244\354\235\230_\354\262\264.py" diff --git "a/INSEA-99/week08/2960_\354\227\220\353\235\274\355\206\240\354\212\244\355\205\214\353\204\244\354\212\244\354\235\230_\354\262\264.py" "b/INSEA-99/week08/2960_\354\227\220\353\235\274\355\206\240\354\212\244\355\205\214\353\204\244\354\212\244\354\235\230_\354\262\264.py" new file mode 100644 index 0000000..a178b66 --- /dev/null +++ "b/INSEA-99/week08/2960_\354\227\220\353\235\274\355\206\240\354\212\244\355\205\214\353\204\244\354\212\244\354\235\230_\354\262\264.py" @@ -0,0 +1,22 @@ +# pypy3 +# 시간(ms) : 92 +# 공간(KB) : 109544 + +import sys +input = sys.stdin.readline + +n, K = map(int, input().strip().split()) + +sieve = [True] * (n + 1) +sieve[0] = sieve[1] = False + +def find_kth_removed(n, K) : + k = 0 + for i in range(2, n + 1): # 소수를 포함하여 지워지는 수를 확인해야하므로 n까지 탐색 + if sieve[i]: # 소수라면 본인과 배수 제거 + for j in range(i, n + 1, i): + if sieve[j]: + sieve[j] = False + k +=1 + if k == K: return j +print(find_kth_removed(n, K)) From 6ab431fe7b1b8cf827469c13e0da18278599c954 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Mon, 3 Nov 2025 23:02:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Solved:=206588=20=EA=B3=A8=EB=93=9C?= =?UTF-8?q?=EB=B0=94=ED=9D=90=EC=9D=98=20=EC=B6=94=EC=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\235\230_\354\266\224\354\270\241.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "INSEA-99/week08/6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230_\354\266\224\354\270\241.py" diff --git "a/INSEA-99/week08/6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230_\354\266\224\354\270\241.py" "b/INSEA-99/week08/6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230_\354\266\224\354\270\241.py" new file mode 100644 index 0000000..858fbff --- /dev/null +++ "b/INSEA-99/week08/6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230_\354\266\224\354\270\241.py" @@ -0,0 +1,28 @@ +# pypy3 +# 시간(ms) : 316 +# 공간(KB) : 119244 + +import sys +input = sys.stdin.readline +MAX = 1_000_000 + +def goldbach_conjecture_check(n) : + for i in range(3, n - 2) : # 홀수 소수 합이 n이 되는지 확인 + if sieve[i] and sieve[n-i]: + return f"{n} = {i} + {n-i}" + return "Goldbach's conjecture is wrong." + +# MAX 값 기준 에라토스테네스의 체 생성 +sieve = [True] * (MAX + 1) +sieve[0] = sieve[1] = False + +for i in range(2, int(MAX ** 0.5) + 1): + if sieve[i]: # 소수라면 배수 제거 + for j in range(i * i, MAX + 1, i): # i*i보다 작은 배수는 중복 처리이기 때문에 i*i 부터 확인 + sieve[j] = False + +# 골드바흐의 추측 검증 +while True : + n = int(input()) + if n == 0 : break + print(goldbach_conjecture_check(n)) \ No newline at end of file From 60bdd2c9d28858fd0e979b9b23ec4ce2af5a6d00 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Tue, 4 Nov 2025 23:51:11 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Solved:=203020=20=EA=B0=9C=EB=98=A5?= =?UTF-8?q?=EB=B2=8C=EB=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\230\245\353\262\214\353\240\210.py" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "INSEA-99/week08/3020_\352\260\234\353\230\245\353\262\214\353\240\210.py" diff --git "a/INSEA-99/week08/3020_\352\260\234\353\230\245\353\262\214\353\240\210.py" "b/INSEA-99/week08/3020_\352\260\234\353\230\245\353\262\214\353\240\210.py" new file mode 100644 index 0000000..755cd5e --- /dev/null +++ "b/INSEA-99/week08/3020_\352\260\234\353\230\245\353\262\214\353\240\210.py" @@ -0,0 +1,37 @@ +# pypy3 +# 시간(ms) : 152 +# 공간(KB) : 118540 +# +# 공유 : +# - gpt가 파이썬은 인덱스를 음수로 반복적으로 접근하면 내부적으로 인덱스 변환을 계속 해야 하므로 느리다함 +# 이 문제 기준으로는 8ms 차이라서 크게 신경 안써도 될듯 (백만 단위 이상 인덱싱에서 3~5% 정도 느리다고) + +import sys +input = sys.stdin.readline + +n, h = map(int, input().strip().split()) + +top = [0] * (h+1) # 종유석 +bottom = [0] * (h+1) # 석순 + +for _ in range(n//2) : # 종유석, 석순 각각 같은 길이 카운팅 + bottom[int(input())] += 1 + top[-int(input())] += 1 + +for i in range(1, h+1) : # 종유석, 석순 각각 누적합을 통해 구간에 따른 hit 구하기 + top[i] += top[i-1] + bottom[-(i+1)] += bottom[-i] + +min_hit = n # 최소 hit +min_hit_cnt = 1 # 최소 hit 개수 +for i in range(1, h+1) : + hit = top[i] + bottom[i] # 종유석, 석순 합쳐서 최종 hit 구하기 + if min_hit > hit : + min_hit = hit + min_hit_cnt = 1 + elif min_hit == hit : + min_hit_cnt += 1 + +print(min_hit, min_hit_cnt) + +