blob: 806fc5171b6f2dfbc33d7a6dc453086011efa497 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// 2165. Tower of Hanoi
#include <bits/stdc++.h>
using namespace std;
void move(int from, int to, int depth) {
if (depth == 1) {
printf("%d %d\n", from, to);
return;
}
int other = 6 - from - to;
move(from, other, depth - 1);
printf("%d %d\n", from, to);
move(other, to, depth - 1);
}
int main() {
static int n;
scanf("%d", &n);
printf("%d\n", (1 << n) - 1);
move(1, 3, n);
}
|