Codeforces Beta Round 40(Div. 2)
E
3-环
3-cycles
Codeforces
1900
原题
← D→

3-环AI (CI翻译)

During a recent research Berland scientists found out that there were $*n*$ cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three cities from each of which one can get to any other one directly. That is, there was no cycle exactly as long as 3. Unfortunately, the road map has not been preserved till nowadays. Now the scientists are interested how much developed a country Ancient Berland was. Help them - find, what maximal number of roads could be in the country. You also have to restore any of the possible road maps.

最近,别尔兰科学家发现,古代别尔兰有 $*n*$ 座城市,它们由双向道路连接。任意两座城市之间至多有一条道路。没有道路连接一座城市和它自己。根据一个众所周知的传统,道路网络的修建方式使得不可能选出三座城市,使得从其中任意一座都可以直接到达另外两座中的任意一座。也就是说,不存在长度恰好为 3 的环。遗憾的是,道路地图没能保存到今天。现在,科学家们想了解古代别尔兰的发达程度。请帮助他们找出这个国家中道路数可能达到的最大值。你还需要恢复任意一种可能的道路地图。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line contains an integer $*n*$ ($1 ≤ *n* ≤ 100$) — the number of cities in Berland.

第一行包含一个整数 $*n*$($1 ≤ *n* ≤ 100$)——别尔兰的城市数量。AI (CI翻译)

Output

输出格式

AI (CI翻译)

On the first line must be printed number $*m*$ — the maximal number of roads in Berland. Then print $*m*$ lines containing two numbers each — the numbers of cities that the given road joins. The cities are numbered with integers from $1$ to $*n*$. If there are several variants of solving the problem, print any of them.

第一行输出一个整数 $*m*$——别尔兰道路数的最大值。接下来输出 $*m*$ 行,每行包含两个整数——该道路连接的城市编号。城市编号为 $1$ 到 $*n*$ 的整数。如果有多种方案,输出任意一种即可。AI (CI翻译)

样例

Input #1
3
Output #1
2
1 2
2 3
InputCopy OutputCopy
Input #2
4
Output #2
4
1 2
2 3
3 4
4 1
InputCopy OutputCopy
题目信息
题号
41E
时间限制
2 s
内存限制
256 MB
标签
构造
图论
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。