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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <bits/stdc++.h>

using namespace std;
int a, licz, licz2, pom;
int main()
{
    cin >> a;
    if (a == 1)
    {
        cout << "2\n2 -1\n-1 -1\n";
    }
    else
    {
        pom = __builtin_clz(a);
        licz = 32 - pom;
        licz2 = 0;
        int licza;
        if (a % 2 == 0)
        {
            licza = 1 + 3 * (licz - 1);
            cout << 1 + 3 * (licz - 1) << endl;

            cout << 2 << " " << 3 << endl;

            licz2 = 2;
        }
        else
        {
            licza = 1 + 3 * (licz - 1) + 1;
            cout << 1 + 3 * (licz - 1) + 1 << endl;

            cout << 2 << " " << 1 + 3 * (licz - 1) + 1 << endl;
            cout << 3 << " " << 4 << endl;
            licz2 = 3;
        }

        pom = 1;
        for (int i = 1; i < licz; i++)
        {
            pom *= 2;
         //   cout << pom << " " << a << " " << (pom & a) << endl;
            if ((pom & a) != 0 && i != licz - 1)
            {
                cout << licz2 + 2 << " " << licza << "\n";
                licz2++;
                cout << licz2 + 1 << " " << licza << "\n";
                licz2++;
            }
            else
            {
                cout << licz2 + 2 << " " << -1 << "\n";
                licz2++;
                cout << licz2 + 1 << " " << -1 << "\n";
                licz2++;
            }
            if (i == licz - 1)
            {
                cout << -1 << " " << -1 << endl;

                licz2++;
            }
            else
            {
                cout << licz2 + 1 << " " << licz2 + 2 << endl;
                licz2++;
            }
        }
    }
}