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
70
71
72
73
74
75
76
#include <iostream>
#include <vector>

using namespace std;
vector <long long> V;
long long t[35],k,z;
long long ta[110];
pair <long long, long long> p[110];
int main()
{
    long long a=1;
    t[0]=1;
    for(long long i=1;i<=34;i++)
    {
        a*=2;
        t[i]=a;
    }
    cin>>k;
    z=34;
     while(z>=0)
    {
        if(k>=t[z])
        {
            V.push_back(t[z]);
            k-=t[z];
        }
        z--;
    }
    ta[99]=1;
    p[99].first=100;
    for(int i=98;i>=34;i-=2)
    {
        ta[i]==ta[i+1]*2;
        ta[i-1]=ta[i+1]*2;
        p[i].first=i+1;
        p[i].second=i+2;
        p[i-1].second=i;
    }
    for(int i=1;i<=V.size();i++)
    {
        for(int j=99;j>=30;j-=2)
        {
            if(ta[j]==V[i-1])
            {
                p[int(V.size())-i+1].first=j;
            }
        }
    }
    for(int i=1;i<V.size();i++)
    {
        p[i].second=i+1;
    }
    cout<<100<<endl;
    for(int i=1;i<=100;i++)
    {
        if(p[i].first==0&&p[i].second==0)
        {
            cout<<-1<<" "<<-1<<endl;
        }
        else
            if(p[i].first==0&&p[i].second!=0)
        {
            cout<<-1<<" "<<p[i].second<<endl;
        }
        else
            if(p[i].first!=0&&p[i].second==0)
        {
            cout<<p[i].first<<" "<<-1<<endl;
        }
        else
        {
            cout<<p[i].first<<" "<<p[i].second<<endl;
        }
    }
    return 0;
}