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

int edges[101][2];

int main() {
  int k;
  std::cin >> k;
  for (int i = 0; i < 101; ++i) {
    edges[i][0] = -1;
    edges[i][1] = -1;
  }

  int curr = 1;
  int target = 100;
  while (k > 1) {
    if (k % 2 == 1) {
      edges[curr][0] = target;
      edges[curr][1] = curr + 1;
      curr++;
      k--;
    }
    else {
      edges[curr][0] = curr + 2;
      edges[curr][1] = curr + 1;
      edges[curr + 1][0] = curr + 2;
      curr += 2;
      k /= 2;
    }
  }

  edges[curr][0] = target;
  while (++curr < target) {
    edges[curr][0] = target;
  }

  std::cout << 100 << std::endl;
  for (int i = 1; i <= 100; ++i) {
    std::cout << edges[i][0] << " " << edges[i][1] << std::endl;
  }

  return 0;
}