From f019d8ad3d7ab6ef23491b75cac432930f17d9b2 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Mon, 3 Nov 2025 21:18:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Solved:=2011659=20=EA=B5=AC=EA=B0=84=20?= =?UTF-8?q?=ED=95=A9=20=EA=B5=AC=ED=95=98=EA=B8=B0=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\265\254\355\225\230\352\270\260_4.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "INSEA-99/week07/11659_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_4.py" diff --git "a/INSEA-99/week07/11659_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_4.py" "b/INSEA-99/week07/11659_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_4.py" new file mode 100644 index 0000000..bd44fdf --- /dev/null +++ "b/INSEA-99/week07/11659_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_4.py" @@ -0,0 +1,19 @@ +# pypy3 +# 시간(ms) : 172 +# 공간(KB) : 127164 + +import sys +input = sys.stdin.readline + +n, m = map(int, input().strip().split()) +sum_arr = [0] # 누적합 리스트 +arr = list(map(int, input().strip().split())) # input list + +sum = 0 +for x in arr : # 누적합 구하기 + sum+=x + sum_arr.append(sum) + +for _ in range(m) : # 구간합 구하기 + l, r = map(int, input().strip().split()) + print(sum_arr[r] - sum_arr[l-1]) \ No newline at end of file From 608d8aa4cbc45feabd138b081539f32d9dd97e04 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Mon, 3 Nov 2025 21:45:05 +0900 Subject: [PATCH 2/4] =?UTF-8?q?11660=20=EA=B5=AC=EA=B0=84=20=ED=95=A9=20?= =?UTF-8?q?=EA=B5=AC=ED=95=98=EA=B8=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\265\254\355\225\230\352\270\260_5.py" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "INSEA-99/week07/11660_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_5.py" diff --git "a/INSEA-99/week07/11660_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_5.py" "b/INSEA-99/week07/11660_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_5.py" new file mode 100644 index 0000000..084f9d0 --- /dev/null +++ "b/INSEA-99/week07/11660_\352\265\254\352\260\204_\355\225\251_\352\265\254\355\225\230\352\270\260_5.py" @@ -0,0 +1,38 @@ +# pypy3 +# 시간(ms) : 276 +# 공간(KB) : 120516 +# +# 공유 : +# - enumerate : 파이썬에서 반복문을 쓸 때, 인덱스(index)와 값(value)를 동시에 얻을 수 있게 해주는 내장 함수 +# +# fruits = ['apple', 'banana', 'cherry'] +# +# ex1) +# for i, fruit in enumerate(fruits): +# print(i, fruit) +# -> +# 0 apple +# 1 banana +# 2 cherry +# +# ex2) +# for i, fruit in enumerate(fruits, start=1): +# print(i, fruit) +# -> +# 1 apple +# 2 banana +# 3 cherry + +import sys +input = sys.stdin.readline + +n, m = map(int, input().strip().split()) +sum_arr = [[0]*(n + 1) for _ in range(n + 1)] # 누적합 리스트 + +for i in range(1, n + 1) : # 누적합 구하기 + for j, x in enumerate(list(map(int, input().strip().split())), start=1) : + sum_arr[i][j] = x + sum_arr[i-1][j] + sum_arr[i][j-1] - sum_arr[i-1][j-1] + +for _ in range(m) : # 누적합 이용해서 답 구하기 + x1, y1, x2, y2 = map(int, input().strip().split()) + print(sum_arr[x2][y2] - sum_arr[x2][y1-1] - sum_arr[x1-1][y2] + sum_arr[x1-1][y1-1]) \ No newline at end of file From b836569cf78136a1966a65507241d4c5bfe36f44 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Mon, 3 Nov 2025 22:20:25 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Solved:=202581=20=EC=86=8C=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week07/2581_\354\206\214\354\210\230.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "INSEA-99/week07/2581_\354\206\214\354\210\230.py" diff --git "a/INSEA-99/week07/2581_\354\206\214\354\210\230.py" "b/INSEA-99/week07/2581_\354\206\214\354\210\230.py" new file mode 100644 index 0000000..0712dd6 --- /dev/null +++ "b/INSEA-99/week07/2581_\354\206\214\354\210\230.py" @@ -0,0 +1,22 @@ +# pypy3 +# 시간(ms) : 92 +# 공간(KB) : 109544 + + +import sys +input = sys.stdin.readline + +m = int(input()) +n = int(input()) + +sieve = [True] * (n + 1) +sieve[0] = sieve[1] = False + +for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: # 소수라면 배수 제거 + for j in range(i * i, n + 1, i): # i*i보다 작은 배수는 중복 처리이기 때문에 i*i 부터 확인 + sieve[j] = False + +primes = [i for i in range(m, n + 1) if sieve[i]] # 범위 내 소수들 + +print(-1 if not primes else f"{sum(primes)}\n{primes[0]}") \ No newline at end of file From 0c398d27739c8fa4999a7a586a04645668f42e84 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Mon, 3 Nov 2025 22:24:01 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Solved:=201929=20=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EA=B5=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0_\352\265\254\355\225\230\352\270\260.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "INSEA-99/week07/1929_\354\206\214\354\210\230_\352\265\254\355\225\230\352\270\260.py" diff --git "a/INSEA-99/week07/1929_\354\206\214\354\210\230_\352\265\254\355\225\230\352\270\260.py" "b/INSEA-99/week07/1929_\354\206\214\354\210\230_\352\265\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..02cc62d --- /dev/null +++ "b/INSEA-99/week07/1929_\354\206\214\354\210\230_\352\265\254\355\225\230\352\270\260.py" @@ -0,0 +1,19 @@ +# pypy3 +# 시간(ms) : 136 +# 공간(KB) : 123940 + +import sys +input = sys.stdin.readline + +m, n = map(int, input().strip().split()) + +sieve = [True] * (n + 1) +sieve[0] = sieve[1] = False + +for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: # 소수라면 배수 제거 + for j in range(i * i, n + 1, i): # i*i보다 작은 배수는 중복 처리이기 때문에 i*i 부터 확인 + sieve[j] = False + +primes = [i for i in range(m, n + 1) if sieve[i]] # 범위 내 소수들 +print(*primes, sep='\n') \ No newline at end of file