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
52
53
54
55
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int k;
    cin >> k;
    if (k == 1)
    {
        cout << "2" << endl;
        cout << "2 -1" << endl;
        cout << "-1 -1";
        return 0;
    }
    vector< vector<int> > g(100, vector<int>(2, -1));
    int m = 30;
    while ((k & (1 << m)) == 0)
        --m;
    g[0][0] = 1;
    g[1][0] = 2;
    g[1][1] = 3;
    for (int i = 2; i < 2 * m; i += 2)
    {
        g[i][0] = i + 2;
        g[i][1] = i + 3;
        g[i + 1][0] = i + 2;
        g[i + 1][1] = i + 3;
    }
    g[2 * m][0] = 99;
    g[2 * m + 1][0] = 99;
    g[0][1] = 2 * m + 2;
    for (int i = 2 * m + 2, j = 2, pos = m - 1; pos >= 0; ++i, j += 2, --pos)
    {
        if (pos != 0)
            g[i][0] = i + 1;
        if ((k & (1 << pos)) > 0)
            g[i][1] = j;
    }
    cout << "100" << endl;
    for (int i = 0; i < 100; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
            if (g[i][j] == -1)
                cout << "-1 ";
            else
                cout << g[i][j] + 1 << " ";
        }
        cout << endl;
    }
    return 0;
}