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
77
78
79
80
81
82
83
84
85
86
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int k;
    cin>>k;
    if(k==1)
    {
        cout<<2<<endl;
        cout<<-1<<" "<<2<<endl;
        cout<<-1<<" "<<-1<<endl;
    }
    else{
    vector<int> cf;
    int ms=0;
    int k2=0;
    while(k>k2)
    {
        int f1=1, f2=1;
        while(f1+f2<=k-k2)
        {
            f2=f2+f1;
            f1=f2-f1;
        }
        cf.push_back(f2);
        k2+=f2;
    }
    vector<pair<int,int> > war;
    vector<pair<int,int> > kr;
    war.push_back({0,0});
    kr.push_back({0,0});
    war.push_back({1,1});
    kr.push_back({2,3});
    int g=cf.size()-1;
    int w=2;
    bool czy=0;
    while(war[war.size()-1].second<cf[0])
    {
        if(kr[w-1].first>-1 && !czy)
        {
            war.push_back({w, war[w-1].second+war[w-2].second});
        }
        else
        {
            war.push_back({w, war[w-2].second});
        }
        if(czy)
        {
            kr.push_back({-2, w+2});
            czy=0;
        }
        else if(cf[g]==war[war.size()-1].second)
        {
            kr.push_back({-1, w+2});
            g--;
            czy=1;

        }
        else
        kr.push_back({w+1,w+2});
        w++;
    }
    kr[kr.size()-1]={-1,-1};
    if(war[war.size()-1].first<kr[kr.size()-2].second)
    {
        kr[kr.size()-2].second=-1;
    }
    for(int i=kr.size()-2; i>0; i--)
    {
        if(kr[i].first==-1)
        {
            kr[i].first=kr.size()-1;
        }
        else if(kr[i].first==-2)
            kr[i].first=-1;
    }
    cout<<kr.size()-1<<endl;
    for(int i=1; i<kr.size(); i++)
    {
        cout<<kr[i].first<<" "<<kr[i].second<<endl;
    }


    }
}