Skip to content

Commit

Permalink
BaekJoon
Browse files Browse the repository at this point in the history
  • Loading branch information
HYUNAHSHIM committed Jul 16, 2021
1 parent 5af7589 commit d558193
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
21 changes: 21 additions & 0 deletions BaekJoon11659.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#BaekJoon11659.py

import sys
input = sys.stdin.readline

N, M = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
result = [0 for _ in range(N)]

for i in range(N):
if i == 0:
result[i] = arr[i]
else:
result[i] = result[i - 1] + arr[i]

for _ in range(M):
i, j = map(int, input().split(" "))
if i == 1:
print(result[j - 1])
else:
print(result[j - 1] - result[i - 2])
14 changes: 14 additions & 0 deletions BaekJoon1541.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# BaekJoon1541.py

arr = input().split("-")
results = []
for i in arr:
cnt = 0
b = i.split("+")
for j in b:
cnt += int(j)
results.append(cnt)
first = results[0]
for i in range(1, len(results)):
first -= results[i]
print(first)
31 changes: 31 additions & 0 deletions BaekJoon1992.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# BaekJoon 1992.py


def solution(arr, pos, x, y, result):
if pos == 1:
return result + str(arr[y][x])
# 모두 같은지 체크
is_same = True
value = arr[y][x]
for i in range(pos):
for j in range(pos):
if arr[y+i][x+j] != value:
is_same = False
# 같으면
if is_same:
return result + str(arr[y][x])
# 다르면
elif not is_same:
result = result + "("
result = solution(arr, int(pos / 2), x, y, result)
result = solution(arr, int(pos / 2), int(x + (pos / 2)), y, result)
result = solution(arr, int(pos / 2), x, int(y + (pos / 2)), result)
result = solution(arr, int(pos / 2), int(x + (pos / 2)), int(y + (pos / 2)), result)
result = result + ")"
return result


N = int(input())
image = [list(map(int, input())) for _ in range(N)]
r = solution(image, N, 0, 0, "")
print(r)
4 changes: 4 additions & 0 deletions BaekJoon2178.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# BaekJoon2178.py


N, M = map(int, input().split(" "))

0 comments on commit d558193

Please sign in to comment.