B - Balanced Neighbors Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 700

問題文

整数 N が与えられます。 頂点に 1 から N の番号がついた N 頂点の無向グラフであって、以下の 2 つの条件を満たすものを 1 つ構成してください。

  • 単純かつ連結
  • ある整数 S が存在して、任意の頂点についてその頂点に隣接する頂点の番号の値の和は S となる

この問題の制約下でそのようなグラフが少なくとも 1 つ存在することが証明できます。

制約

  • 入力は全て整数である。
  • 3 \leq N \leq 100

入力

入力は以下の形式で標準入力から与えられる。

N

出力

1 行目に構成したグラフの辺の本数 M を出力せよ。続く M 行のうち i 行目には、2 つの整数 a_ib_i を出力せよ。これらは i 番目の辺の端点を表す。

構成されたグラフが条件を満たすならば正解となる。


入力例 1

3

出力例 1

2
1 3
2 3
  • どの頂点も、隣接する頂点の番号の和が 3 となっています。

Score : 700 points

Problem Statement

You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:

  • The graph is simple and connected.
  • There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.

It can be proved that at least one such graph exists under the constraints of this problem.

Constraints

  • All values in input are integers.
  • 3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

In the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.

The output will be judged correct if the graph satisfies the conditions.


Sample Input 1

3

Sample Output 1

2
1 3
2 3
  • For every vertex, the sum of the indices of the vertices adjacent to that vertex is 3.