-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5af7589
commit d558193
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# BaekJoon2178.py | ||
|
||
|
||
N, M = map(int, input().split(" ")) |