CF41E.3-cycles

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

最近,Berland 的科学家们发现古代 Berland 有 nn 座城市,由双向路径连接。任意两座城市之间至多只有一条路径相连,且不存在连接某座城市与其自身的路径。根据一项广为人知的传统,该道路网络的修建方式使得:无法选出三座城市,使得其中任意两座城市之间都可直接到达。换言之,图中不存在长度恰好为 3 的环(即三角形)。遗憾的是,这张道路地图未能保存至今。如今,科学家们希望了解古代 Berland 的发达程度。请帮助他们——找出该国最多可能拥有的道路数量,并构造出任意一种满足条件的道路图

输入格式

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

第一行包含一个整数 $ n 1 \leq n \leq 100 $)—— Berland 的城市数量。

输出格式

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.

第一行必须输出数字 mm —— Berland 中道路的最大数量。然后输出 mm 行,每行包含两个数字 —— 该道路所连接的两座城市的编号。城市编号为从 11nn 的整数。如果存在多种解法,输出任意一种即可。

输入输出样例

  • 输入#1

    3

    输出#1

    2
    1 2
    2 3
  • 输入#2

    4

    输出#2

    4
    1 2
    2 3
    3 4
    4 1

输入解题思路,AI测评打分。不知道怎么写?

首页