https://www.acmicpc.net/problem/11729
#include <iostream>
#include <cmath>
using namespace std;
int n;
void movePlateFromTo(int from,int middle, int to,int count) {
if (count == 1) {
cout << from << " " << to << "\n";
return;
}
movePlateFromTo(from, to, middle, count -1); //흐름 2
cout << from << " " << to << "\n"; //흐름 3
movePlateFromTo(middle, from, to, count -1); //흐름 4
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
cout << (int)pow(2, n) - 1 << "\n";
movePlateFromTo(1, 2,3,n);
return 0;
}
알고리즘 강의 들으면서 배웠던 기억을 살려가면서 풀었다..
n과 n-1 로 분리해서 푼다는 원리가 기억에 남아있어서 풀 수 있었다.
이게 기억에 남는게 진짜 신기하다 이래서 강의를 열심히 들어야하나보다