
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
N,r,c = map(int, input().split(' ')) | |
count = 0 | |
def divide(size, x, y): | |
global count | |
if size <= 2: | |
if(x==r and y==c): | |
print(count) | |
return | |
count+=1 | |
if(x==r and y+1==c): | |
print(count) | |
return | |
count+=1 | |
if(x+1==r and y==c): | |
print(count) | |
return | |
count+=1 | |
if(x+1==r and y+1==c): | |
print(count) | |
return | |
count+=1 | |
return | |
divide((size//2), x,y) ## size-1로 하면 index 이동할때 계산 불편 | |
divide((size//2), x,y+(size//2)) | |
divide((size//2), x+(size//2),y) | |
divide((size//2), x+(size//2),y+(size//2)) | |
if __name__=="__main__": | |
divide(2**N,0,0) |
'Programming > Algorithm' 카테고리의 다른 글
백준 #10830 - 행렬 제곱 (0) | 2019.11.26 |
---|---|
백준 #2740 - 행렬 곱셈 (0) | 2019.11.25 |
백준 #2263 - 트리의 순회 (0) | 2019.11.23 |
백준 #11729 - 하노이 탑 이동 순서 (0) | 2019.11.23 |
백준 #1780 - 종이의 개수 (0) | 2019.11.23 |