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
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void buildGraph(int size, vector<pair<int, int>> &graph) {
    graph.emplace_back(-1, -1);
    graph.emplace_back(-1, 0);

    for (int i = 2; i <= size; i++) {
        graph.emplace_back(i - 1, i - 2);
    }
}

int main() {
    vector<long> nums = {0, 1, 2};

    while (nums[nums.size() - 1] < 1000000000) {
        nums.push_back(nums[nums.size() - 1] + nums[nums.size() - 2]);
    }

    vector<int> parts;
    long n;
    cin >> n;

    while (n > 0) {
        auto i = lower_bound(nums.begin(), nums.end(), n) - nums.begin();
        if (nums[i] > n) i--;
        parts.push_back(i);
        n -= nums[i];
    }

    vector<pair<int, int>> graph;
    buildGraph(parts[0], graph);
    for (int i = 1; i < parts.size(); i++) {
        graph.emplace_back(graph.size() - 1, parts[i]);
    }

    cout << graph.size() << endl;

    for (int i = graph.size() - 1; i >= 0; i--) {
        auto pair = graph[i];
        cout << ((pair.first == -1) ? -1 : (int) graph.size() - pair.first) << " "
             << ((pair.second == -1) ? -1 : (int) graph.size() - pair.second) << endl;
    }
    return 0;
}