QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#12632. 计数图

統計

首先,让我们定义无向连通标号图:它是一个具有 $N$ 个节点的图,每个节点都有唯一的标号,且包含若干条边。边没有特定的方向,不允许存在重边和自环,且任意两个节点之间都是可达的。

在此问题中,给定 $N$ 和 $K$,你的任务是计算恰好有 $N$ 个节点和 $K$ 条桥的无向连通标号图的数量。由于该数字可能非常大,请输出其对 $M$ 取模的结果。

边由其连接的节点标号定义,例如 $(X, Y)$ 和 $(Y, X)$ 被视为同一条边(因为图是无向的)。如果两个图的边集不同,则认为这两个图不同。

输入格式

程序将测试一个或多个测试用例。输入的第一行是一个整数 $T$ ($1 \le T \le 100$),表示测试用例的数量。随后是 $T$ 个测试用例。

每个测试用例包含一行,由 3 个空格分隔的整数组成:$N$ ($1 \le N \le 50$),$K$ ($0 \le K < N$) 和 $M$ ($1 \le M \le 10^9$),这些数字的含义如上所述。

保证在 95% 的测试用例中,$N$ 不会超过 25。

输出格式

对于每个测试用例,输出一行,表示符合上述条件的图的数量对 $M$ 取模的结果。

样例

输入 1

4
3 2 10
3 0 10
6 3 10000
6 3 1000

输出 1

3
1
2160
160

说明

以下是第一个测试用例中的 3 个图:

以下是第二个测试用例中唯一的图:

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.