Universal Cup Judging System

Universal Cup

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓
Estadísticas

唯美主義者矮人係一位出名嘅藝術鑑賞家。喺佢屋企收藏咗大量畫作。佢最鍾意嘅一幅畫描繪咗一個有 10 個頂點嘅圖,如下圖所示:

problem_16010_1.png

第一個範例輸出嘅示意圖。

有一日,喺欣賞緊佢最鍾意嘅畫作時,呢位矮人發現咗呢個圖之所以咁出色嘅原因:佢係連通嘅,每個頂點恰好有 3 條關聯邊,而且圖入面唔包含長度為 4 嘅環(即係話,對於任意四個唔同嘅頂點 $v_1, v_2, v_3, v_4$,都唔存在四條邊 $(v_1, v_2)$、$(v_2, v_3)$、$(v_3, v_4)$ 同 $(v_4, v_1)$)。

意識到呢一點之後,唯美主義者矮人為之震驚,佢想知道係咪仲存在其他具有呢啲性質嘅圖。由於佢想成為藝術界嘅大人物,佢只係對大型嘅圖感興趣,即係頂點數至少為 42 嘅圖(對佢嚟講,42 似乎係一個好型嘅數字)。

請幫下呢位矮人:對於給定嘅頂點數,構造一個具有呢啲性質嘅無向簡單圖(冇自環,而且同一對頂點之間冇重邊),或者判定唔存在咁樣嘅圖。

輸入格式

輸入嘅第一行亦係唯一一行包含一個整數 $N$,表示頂點嘅數量。

輸出格式

如果唔存在滿足條件嘅解,輸出 NO。

否則,喺第一行輸出一個整數 $M$,表示圖入面邊嘅數量。

接落嚟嘅 $M$ 行,每行應包含兩個整數 $a_i$ 同 $b_i$ ($1 \le a_i, b_i \le N$),表示一條邊嘅兩個端點。

如果存在多個合法嘅解,你可以輸出其中任意一個。

數據範圍

$42 \le N \le 10^6$。

範例

輸入 1

10

輸出 1

15
1 2
2 3
3 4
4 5
5 1
1 6
2 7
3 8
4 9
5 10
6 8
8 10
10 7
7 9
9 6

輸入 2

8

輸出 2

NO

提示

注意:上面嘅範例並唔滿足 $N \ge 42$ 嘅條件,所以你唔需要通過呢啲範例。評測系統入面嘅範例滿足 $N = 42$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.