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
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;

ll ile[101];

int L[101];
int R[101];

int main(void){
    ll k;
    int nr = 0;
    scanf("%lld",&k);
    L[100] = R[100] = -1;
    ile[100] = 1;
    for(int i = 99; i >= 1;i--){
        if(i%2 == 1){
            L[i] = i+1;
            R[i] = -1;
            ile[i] = ile[i+1];
        }else{
            L[i] = i+1;
            R[i] = i+2;
            ile[i] = ile[i+1] + ile[i+2];
        }
        if(ile[i] > k){
            nr = i-1;
            break;
        }
    }
    bool pierwszy = 1;
    ll p = 1;
    while(k != 0){
        if(k%2 == 1){

            if(pierwszy){
                R[nr] = -1;
                pierwszy = 0;
            }else{
                R[nr] = nr+1;
            }

            for(int i = 100; i >= 1;i--){
                if(ile[i] == p){
                    L[nr] = i;
                    break;
                }
            }
            nr--;
        }
        p *= 2;
        k /= 2;
    }
    for(int i = nr; i >= 2;i--){
        L[i] = R[i] = -1;
    }
    L[1] = nr+1;
    R[1] = -1;
    printf("100\n");
    for(int i = 1; i <= 100;i++){
        printf("%d %d\n",L[i],R[i]);
    }

    return 0;
}