#P4233. 射命丸文的笔记

    ID: 3166 远端评测题 1000~2000ms 125MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>O2优化剪枝强连通分量,缩点概率论,统计期望快速傅里叶变换 FFT

射命丸文的笔记

Description

If a tournament contains a Hamiltonian cycle, then we call this tournament “worth recording.”

Choose uniformly at random from all “worth recording” tournaments with nn pairwise distinct vertices.

Find the expected number of Hamiltonian cycles in the chosen tournament.

Since the answer may be too large or lose precision, you only need to output the answer modulo 998244353998244353.

That is: let the answer be qp\frac{q}{p}. You must output an integer xx such that pxqmod998244353p x \equiv q \bmod 998244353 and 0x<9982443530 \leqslant x < 998244353. It can be proved that such an xx exists and is unique.

If no such tournament exists, output -1.

Input Format

One line with a positive integer nn.

Output Format

Output nn lines. On line ii, print the answer for input ii.

4
1
-1
1
1

Hint

Sample explanations:

  • When n=1n=1, there is only one tournament, which is a single vertex.
  • When n=2n=2, the tournament has only one edge and cannot form a Hamiltonian cycle.
  • When n=3n=3, there are two “worth recording” tournaments, namely 12311\to2\to3\to1 and 13211\to3\to2\to1, each having exactly 11 Hamiltonian cycle, so the expected value is 11.
  • When n=4n=4, there are many “worth recording” tournaments (too many to list here), but all that satisfy the condition are isomorphic, so the expected value is 11.

Constraints:

  • In test points 1–3, n7n \leqslant 7.
  • In test points 4–6, n10n \leqslant 10.
  • In test points 7–10, n1000n \leqslant 1000.
  • In test points 11–16, n10000n \leqslant 10000.
  • In test points 17–25, n100000n \leqslant 100000.

The testdata has a gradient; each test point is worth 4 points.

To avoid constant-factor issues, the last two points have a 2 s time limit.

Terminology:

by oscar

Translated by ChatGPT 5