QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#16861. Petya 的密码学

统计

Petya 的密码学课程不及格,但那是因为老师们无法理解他的天才,而不是因为他懒惰。为了向全世界证明他的天才,Petya 发明了一种新的公钥加密系统——PSA。任何一个体面的公钥密码系统都包含一个公钥和一个私钥。

Petya 选择一棵树 $T$ 作为私钥,并选择两个数 $(n, p)$ 作为公钥,其中 $n$ 是树 $T$ 中的顶点数,$p$ 是树 $T$ 中长度为 2 的路径数量。回想一下,树是一个不含环的无向连通图。

Petya 密码系统的奇特之处在于,任何与公钥相对应的私钥都足以破解它。但这并不是问题,因为 Petya 选择了一个相当复杂的任务,对吧?请还原出密码系统 PSA 的任意一个私钥,或者声明这样的公钥是不可能产生的。

输入格式

输入仅包含一行,其中有两个整数 $n$ 和 $p$ ($1 \le n \le 1000$, $0 \le p \le 10^9$)。

输出格式

如果存在解,第一行输出 “Yes”。在接下来的 $n-1$ 行中,输出两个 $1$ 到 $n$ 之间的不同整数,表示树的边。

如果不存在解,在单行中输出 “No”。

样例

输入样例 1

7 11

输出样例 1

Yes
1 2
2 3
3 4
3 5
3 6
3 7

输入样例 2

5 5

输出样例 2

No

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.