QOJ.ac

QOJ

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

#5746. DAG 生成

統計

为了生成一个有向无环图(DAG),我们从一个空的 DAG 顶点集合 $A$ 和候选顶点集合 $B = \{1, 2, \dots, n\}$ 开始。

然后,我们按照以下方式逐个将顶点添加到 DAG 中:

  1. 我们从 $A$ 中选取一个子集 $X \subseteq A$,并从 $B$ 中均匀随机选取一个顶点 $u$;
  2. 我们从 $X$ 中的所有顶点向 $u$ 连边;
  3. 我们将 $u$ 添加到 $A$ 中,并从 $B$ 中移除 $u$。

最终,我们得到了一个包含 $n$ 个顶点的 DAG。我们执行了两次该过程,生成了两个包含 $n$ 个顶点的 DAG。这两个 DAG 不同的概率是多少?

如果两个 DAG 的有向边集合不同,则认为它们是不同的。

输入格式

每个测试包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 10^5$)。

接下来是各测试用例的描述。

每个测试用例的第一行包含一个整数 $n$ ($1 \le n \le 10^5$),即 DAG 中的顶点数量。

输出格式

对于每个测试用例,输出两个 DAG 不同的概率,结果对 $10^9 + 9$ 取模。

形式化地,令 $M = 10^9 + 9$。可以证明答案可以表示为不可约分数 $\frac{p}{q}$,其中 $p$ 和 $q$ 为整数且 $q \not\equiv 0 \pmod M$。输出等于 $p \cdot q^{-1} \pmod M$ 的整数。换句话说,输出一个整数 $x$,满足 $0 \le x < M$ 且 $x \cdot q \equiv p \pmod M$。

样例

输入 1

4
1
2
3
100

输出 1

0
375000004
117187502
778748905

说明

当 $n = 2$ 时,答案为 $\frac{5}{8}$。 当 $n = 3$ 时,答案为 $\frac{121}{128}$。

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.