[백준] 카드 역배치 10804 C++
https://www.acmicpc.net/problem/10804 12345678910111213141516171819202122232425262728293031323334353637#include #include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); vector v; int array1[21] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; int A, B; int temp; for (int cnt = 0; cnt > A >> B; for (int i = A; i
[백준] 하노이 탑 이동 순서 11729 Python (재귀)
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: result.append(str(fromm)+" "+str(to)) else: hanoi(n-1, fromm, to, by) result.append(str(fromm)+" "+str(to)) hanoi(n-1, by, fromm, to) n = int(input()) hanoi(n,1,2,3) print(cnt) for i in result: print(i)