Skip to content

Commit 07828f0

Browse files
committed
[BOJ] #1074. Z / 실버1 / 58분 / 실패
1 parent 0325aaf commit 07828f0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
def z_order(N, r, c):
5+
if N == 0: # Base case: 크기가 1x1인 경우
6+
return 0
7+
half = 2 ** (N - 1)
8+
if r < half and c < half: # 1사분면
9+
return z_order(N - 1, r, c)
10+
elif r < half and c >= half: # 2사분면
11+
return half * half + z_order(N - 1, r, c - half)
12+
elif r >= half and c < half: # 3사분면
13+
return 2 * half * half + z_order(N - 1, r - half, c)
14+
else: # 4사분면
15+
return 3 * half * half + z_order(N - 1, r - half, c - half)
16+
17+
N, r, c = map(int, input().split())
18+
print(z_order(N, r, c))

0 commit comments

Comments
 (0)