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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>

using namespace std;

int main() {

    int a[35], n, m;
    cin >> m;
    n = m;
    int i;
    if (m == 1) {
        cout << 2 << endl;
        cout << 2 << " " << -1 << endl;
        cout << -1 << " " << -1 << endl;
        return 0;
    }
    for(i=0; n>0; i++)    
    {    
        a[i] = n%2;    
        n = n/2;  
    }
    cout << 3*i+2 << endl;

    cout << 2 << " " << -1 << endl;
    for (int j = 0; j < i; j++) {
        cout << j + i + 2 << " " << -1 << endl;
    }

    for (int j = 0; j < i - 1; j++) {
        cout << j + 3 << " " << j + 2*i + 2 << endl;
    }
    cout << 3*i + 1 << " " << -1 << endl;

    for (int j = 0; j < i; j++) {
        if (j == i-1) {
            if (a[j] == 1)
                cout << i*3 + 2 << " " << -1 << endl;
            else 
                cout << -1 << " " << -1 << endl;
        }
        else {
            if (a[j] == 1)
                cout << j+3 << " " << i*3 + 2 << endl;
            else
                cout << j+3 << " " << -1 << endl;
        }
    } 
    cout << -1 << " " << -1;

    return 0;
}