#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
void f(int n, char a, char b, char c) {
if (n == 0) {
return;
}
else {
f(n - 1, a, c, b);
cout << a << " " << c << endl;
f(n - 1, b, a, c);
}
}
void solve() {
int n;cin >> n;
f(n, 'A', 'B', 'C');
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int t = 1;
//cin >> t;
for (int i = 1; i <= t; i++) {
//cout << "----Test " << i << "----" << endl;
solve();
}
return 0;
}
经典递归回溯

京公网安备 11010502036488号