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
#include<bits/stdc++.h>
using namespace std;
#define magiczne ios_base::sync_with_stdio(0);
#define linijki cin.tie(0);
int n = 2, k, edge[107], tab[107], x;
int main()
{
    magiczne linijki
    for (int i = 0; i < 107; ++i)
        edge[i] = -1, tab[i] = 1;
    cin >> k;
    while (1)
    {
        for (x = 0; x < n - 1; ++x)
        {
            if (tab[x] + tab[n - 1] > k)
                break;
        }
        edge[n] = --x;
        tab[n] = tab[n - 1] + tab[x];
        if (tab[n] == k) break;
        n++;
    }
    cout << ++n << '\n';
    for (int i = n - 1; i >= 0; --i)
    {
        if (i) cout << n - i + 1 << ' ';
        else cout << "-1 ";
        if (edge[i] + 1) cout << n - edge[i]<< '\n';
        else cout << "-1\n";
    }
    return 0;
}