Advertisement
Josif_tepe

Untitled

Jan 12th, 2023
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. using namespace std;
  5.  
  6.  
  7. void rec(int N, int first_tower, int second_tower, int third_tower) {
  8.     if(N == 0) {
  9.         return;
  10.     }
  11.     rec(N - 1, first_tower, third_tower, second_tower);
  12.     cout << first_tower << " " << third_tower << endl;
  13.     rec(N - 1, second_tower, first_tower, third_tower);
  14. }
  15. int main() {
  16.     int N;
  17.     cin >> N;
  18.     cout << (1 << N) - 1 << endl;
  19.     rec(N, 1, 2, 3);
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement