P26402 [AtCoder] Snuke's Growth - Ring -
提高+
题目描述

Problem Description

You are enjoying "Snuke's Growth". Snuke has become surprisingly intelligent!

Having leveled up and gained wisdom rapidly, Snuke is now venturing into various businesses. Wanting to see Snuke working hard, you decided to build an office for him.

Having saved up your in-game currency, you finally obtained the item "Infinite Ring" to design Snuke's living space. The "Infinite Ring" can be used as a closed curve of any length on a plane and can be placed to satisfy the following conditions:

  • Choose at most 5000 points on the "Infinite Ring". These chosen points are called pillar points. At pillar points, the "Infinite Ring" must turn at a right angle. It must not turn at any other points.
  • The segments between two pillar points must be parallel to either the x-axis or the y-axis.
  • All pillar points must be placed on points on the plane where both the x-coordinate and y-coordinate are integers with absolute values no more than $10^9$.
  • For all pillar points, the point on the plane where they are placed must not be crossed by any other part of the "Infinite Ring". Self-intersection of the "Infinite Ring" at points other than pillar points is allowed.
  • The "Infinite Ring" must divide the entire plane (including the outer plane) into exactly $K$ parts.

The first configuration in the figure below satisfies the conditions, but the second and third configurations do not, as the "Infinite Ring" passes through the points where pillar points are placed more than once.

Given $K$, find a configuration that satisfies the conditions.

Input Format

The input is given from the standard input in the following format:

$ K $

Output Format

First, output the number of pillar points $N$. Then, output the coordinates where the $N$ pillar points are placed in order. On the $i$-th line, output the integer representing the x-coordinate and the integer representing the y-coordinate of the $i$-th point, separated by a space.

Sample Input and Output

Sample Input #1

3

Sample Output #1

6
1 5
1 3
5 3
5 1
3 1
3 5

Sample Input #2

6

Sample Output #2

12
2 0
0 0
0 2
6 2
6 0
4 0
4 6
6 6
6 4
0 4
0 6
2 6

Notes/Hints

Constraints

  • $2 \leq K \leq 10^6$

Sample Explanation 1

As shown in the figure below, the plane is divided into 3 parts.

Sample Explanation 2

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3
样例输出
6 1 5 1 3 5 3 5 1 3 1 3 5