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 <algorithm>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int K;
	cin >> K;

	const int NF = 44;
	int fibs[NF];
	fibs[0] = 1;
	fibs[1] = 1;
	for (int i = 2; i < sizeof(fibs)/sizeof(fibs[0]); i++)
		fibs[i] = fibs[i-1] + fibs[i-2];

	auto k = K;
	int steps = 0;
	int fibsize = upper_bound(&fibs[0], &fibs[NF], k)-&fibs[0];
	while (k>0) {
		auto it = upper_bound(&fibs[0], &fibs[NF], k);
		it--;
		k -= *it;
		steps++;
	}
	int last = steps + fibsize + 3;
	cout << last << endl;
	cout << 2 << " " << fibsize + 3 << endl;
	for (int i = 0; i < fibsize-1; i++)
		cout << i + 3 << " " << i + 4 << endl;
	cout << last << " -1" << endl;
	cout << "-1 -1" << endl;

	int current = 3 + fibsize;
	K -= fibs[fibsize-1];
	while (K > 0) {
		auto it = upper_bound(&fibs[0], &fibs[NF], K);
		it--;
		cout << current + 1 << " " << fibsize - (it - &fibs[0]) + 1 << endl;
		K -= *it;
		current++;
	}
	cout << "-1 -1" << endl;
	cout << "-1 -1" << endl;

	return 0;
}