-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBACKJOON1074.py
More file actions
35 lines (29 loc) · 833 Bytes
/
BACKJOON1074.py
File metadata and controls
35 lines (29 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Z
import sys
input = sys.stdin.readline
def find(size, r, c, result):
if size == 2:
if r == 0 and c == 0:
return result
elif r == 0 and c == 1:
return result + 1
elif r == 1 and c == 0:
return result + 2
elif r == 1 and c == 1:
return result + 3
half = size // 2
if half < (r + 1):
if half < (c + 1):
return find(half, r - half, c - half, result) + half*half*3
else:
return find(half, r - half, c, result) + half*half*2
else:
if half < (c + 1):
return find(half, r, c - half, result) + half*half
else:
return find(half, r, c, result)
n, r, c = map(int, input().split(" "))
size = pow(2, n)
result = 0
result = find(size, r, c, result)
print(result)