Universal Cup Judging System

Universal Cup

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

僅使用電阻值為 $1\,[\Omega]$ 的電阻,建構一個電阻值為 $\sqrt{D}\,[\Omega]$ 的電阻器。

給定一個正整數 $D$。請建構一個滿足以下所有條件的連通無向圖。在題目限制下,可以證明這樣的圖一定存在。

  • 頂點數 $N$ 在 $2$ 到 $300$ 之間(含),且每個頂點都有一個從 $1$ 到 $N$ 的相異標籤。
  • 邊數 $M$ 最多為 $300$,允許自環與重邊。
  • 「從頂點 $1$ 到頂點 $N$ 的等效電阻」(定義如下)與 $\sqrt{D}$ 的絕對誤差在 $\pm 10^{-6}$ 以內。

令 $G$ 為一個具有 $n$ 個頂點與 $m$ 條邊的連通無向圖($n \ge 2$),假設第 $j$ 條邊連接頂點 $a_j, b_j$。考慮為圖 $G$ 的每個頂點指定一個實數 $V_i$ ($i = 1, 2, \dots, n$),並為每條邊指定一個實數 $I_j$ ($j = 1, 2, \dots, m$),使得以下所有方程式成立:

  • $I_j = V_{a_j} - V_{b_j}$ ($j = 1, 2, \dots, m$)
  • $\sum_{b_j=i} I_j - \sum_{a_j=i} I_j = 0$ ($i = 2, 3, \dots, n - 1$)
  • $\sum_{b_j=n} I_j - \sum_{a_j=n} I_j = 1$

可以證明這樣的指定方式一定存在,且 $V_1 - V_n$ 的值是唯一確定的。我們將此值定義為「從頂點 $1$ 到頂點 $n$ 的等效電阻」。

輸入格式

輸入包含一個正整數 $D$。($1 \le D \le 5000$)

輸出格式

在第一行,輸出所建構圖的頂點數 $N$ 與邊數 $M$,兩者以空格分隔。

在接下來的 $M$ 行中,第 $i$ 行 ($i = 1, 2, \dots, M$) 應包含第 $i$ 條邊的兩個端點,以空格分隔。

若有多個圖滿足條件,輸出其中任意一個即可。

範例

輸入格式 1

1

輸出格式 1

4 5
1 2
1 3
2 3
2 4
3 4

說明

下圖為範例一輸出結果的示意圖。

從頂點 $1$ 到頂點 $n$ 的等效電阻為 $1\,[\Omega]$,解釋如下:

  • 由於所有電阻的電阻值皆為 $1\,[\Omega]$,且根據對稱性,頂點 $2$ 與 $3$ 的電位相等,因此兩者之間的電阻可視為不存在。
  • 結果電路簡化為兩個並聯的分支,每個分支由兩個串聯的 $1\,[\Omega]$ 電阻組成。
  • 兩個 $1\,[\Omega]$ 電阻串聯的等效電阻為 $2\,[\Omega]$,而兩個 $2\,[\Omega]$ 電阻並聯的等效電阻為 $1\,[\Omega]$。

以下輸出也被視為正確:

2 1
1 2

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1532EditorialOpen题解jiangly2026-04-15 16:05:36View

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.