1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
cnt = 0
result = []
def hanoi(n, fromm, by, to):
global cnt
cnt += 1
if n == 1:
else:
hanoi(n-1, fromm, to, by)
hanoi(n-1, by, fromm, to)
n = int(input())
hanoi(n,1,2,3)
print(cnt)
for i in result:
print(i)
|
'Algorithm > BOJ 기초' 카테고리의 다른 글
[백준] 로또 6603 Python (0) | 2019.10.18 |
---|---|
[백준] 괄호 9012 Python (0) | 2019.10.18 |
[백준] 10773 제로 Python C++ (0) | 2019.10.08 |
[백준] 11047 동전0 Python C++ (0) | 2019.10.08 |
[백준] 2581 소수 Python (주어진 범위 내 소수들의 합, 최소값) (0) | 2019.10.08 |