1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
int k;
vector<bool> k_bitmap;
int main() {
    cin >> k;
    int k2 = k;
    while (k2 != 0) {
        k_bitmap.push_back(k2 % 2);
        k2 /= 2;
    }
    int len = k_bitmap.size() - 1;
    int n = 2 + len*3;
    cout << n << endl;
    for (int i = 1; i <= n-1; i++) {
        if (i == n - 1) {
            cout << i + 1 << " -1" << endl;
        } else if (i % 3 == 1) {
            cout << i + 1 << " " << i + 2 << endl;
        } else if (i % 3 == 0) {
            cout << i + 1 << " -1" << endl;
        } else {
            if (k_bitmap[i / 3]) {
                cout << i + 2 << " " << n << endl;
            } else {
                cout << i + 2 << " -1" << endl;
            }
        }
    }

    cout << "-1 -1" << endl;
    return 0;
}