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
87
88
89
90
91
92
93
94
95
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define LIM 50

int next_node, n = 100, k, start_fib = 50, start_dist = 16;
//int next_node, n = 20, k, start_fib = 10, start_dist = 4;
int res[107][2];

ll base[LIM + 1];
ll fib[LIM + 1];

void construct_fib(){
  res[start_fib][0] = n;
  res[start_fib+1][0] = start_fib;
  res[start_fib+1][1] = n;
  for(int i = start_fib + 2; i < 100; i++){
    res[i][0] = i-1;
    res[i][1] = i-2;
  }
}

void construct_dist(){
  for(int i = 1; i < start_dist; i++){
    res[i][0] = 2 * i;
    res[i][1] = 2 * i + 1;
  }
}

void connect(){
  next_node = start_dist;
  int leg = 0;
  for(int i = 0; i <LIM; i++){
    if (base[i]){
      res[next_node][leg] = i + start_fib - 2;
      if (leg){
        leg = 0; next_node++;
      } else{
        leg++;
      }
    }
  }
}

int main(){
  fib[1] = 1;
  fib[2] = 1;
  for(int i = 3; i<=LIM;i++){
    fib[i] = fib[i-1] + fib[i-2];
  }
  construct_fib();
  construct_dist();
  //printf("first couple of fib numbers:\n");

  /*for(int i = 1; i < 10; i++){
    printf("%lld\t", fib[i]);
  })*/
  // fib 45 is already more than I need
  scanf("%d", &k);
  //printf("\n%d in fib base:\n", k);

  int idx = LIM;
  while(k>0){
    while(fib[idx] > k) idx--;
    while(idx && fib[idx] <= k){
      base[idx]++;
      k-= fib[idx];
    }
  }
  // max 23 fibits on, as fib two consecutive fibits cannot be on

  /*
  for(int i = 1; i < 10; i++){
    printf("%d\t",base[i]);
  }
  for(int i = LIM; i >= 0; i--){
    if (base[i]){
      printf("highest fibit on: %d\n", i);
      break;
    }
  }
  printf("\n");*/
  connect();

  printf("%d\n", n);
  for(int i = 1; i<=n;i++){
    for(int j = 0; j < 2; j++){
    if (!res[i][j])
      res[i][j] = -1;
    }
    printf("%d %d\n", res[i][0], res[i][1]);
  }


}