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
#include <iostream>
using namespace std;

int en = 708;
int e[105][2];
int n;

void cccc(int poc, int k)
{
    if (k == 1)
    {
        e[poc][0] = en;
        n = poc + 1;
        return;
    }
    e[poc][0] = poc + 1;
    e[poc][1] = poc + 2;
    e[poc + 1][0] = poc + 2;
    cccc(poc + 2, k/2);
    if (k & 1) e[poc + 1][1] = en;
    return;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    cccc(1, k);
    cout << n << '\n';
    {
        for (int i = 1; i <= n; i++)
        {
            if (e[i][0] == en) cout << n;
            else if (e[i][0] == 0) cout << -1;
            else cout << e[i][0];
            cout << " ";
            if (e[i][1] == en) cout << n;
            else if (e[i][1] == 0) cout << -1;
            else cout << e[i][1];
            cout << "\n";
        }
    }
}