Blog of RuSun

\begin {array}{c} \mathfrak {One Problem Is Difficult} \\\\ \mathfrak {Because You Don't Know} \\\\ \mathfrak {Why It Is Diffucult} \end {array}

P4233 射命丸文的笔记

P4233 射命丸文的笔记

考虑所有竞赛图上所有哈密顿路径的数量。考虑圆排列的数量 $(n - 1)!$ 个,剩下的 $\frac {n (n - 1)} 2 - n$ 条边随便选择,那么答案为 $(n - 1)! 2 ^ {\frac {n (n - 1)} 2 - n}$ 。

考虑所有竞赛图中有哈密顿路径的数量。注意到图上缩点后的形态,一定是一个链状的图,每一个点向后面的点连边,如果有一个哈密顿路径,那么所有点都在一个强连通分量上。$n$ 个点的竞赛图有生成函数 $F(x) = \sum _ {i = 0} 2 ^ {\binom n 2} x ^ i$ 。考虑其中有多少个强连通块,将每个点分到其中一个强连通分量,强连通分量间有顺序,强连通分量内没有顺序,考虑 EGF ,$G(x)$ 表示 $n$ 个点的只有一个强连通分量的图的个数,那么 $k$ 个强连通分量即 $G(x) ^ k$ 。那么有 $F(x) = \sum _ {i = 0} G(x)$ ,即 $G(x) = 1 - \frac 1 {F(x)}$ 。

最终答案 $\frac {(n - 1)! 2 ^ {\frac {n (n - 1)} 2 - n}} {n!G(n)}$ 。

查看代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <cstdio>
#include <algorithm>
using namespace std;
template <class Type>
void read (Type &x)
{
char c;
bool flag = false;
while ((c = getchar()) < '0' || c > '9')
flag |= c == '-';
x = c - '0';
while ((c = getchar()) >= '0' && c <= '9')
x = (x << 3) + (x << 1) + c - '0';
if (flag) x = ~x + 1;
}
template <class Type, class ...Rest>
void read (Type &x, Rest &...y) { read(x); read(y...); }
template <class Type>
void write (Type x)
{
if (x < 0) putchar('-'), x = ~x + 1;
if (x > 9) write(x / 10);
putchar('0' + x % 10);
}
typedef long long LL;
const int N = 5e5 + 10, mod = 998244353, inv2 = mod + 1 >> 1;
int rev[N];
int binpow (int b, int k = mod - 2)
{
int res = 1;
for (; k; k >>= 1, b = (LL)b * b % mod)
if (k & 1) res = (LL)res * b % mod;
return res;
}
void ntt (int *x, int bit, int op)
{
int tot = 1 << bit;
for (int i = 1; i < tot; ++i)
if ((rev[i] = rev[i >> 1] >> 1 | (i & 1) << bit - 1) > i)
swap(x[rev[i]], x[i]);
for (int mid = 1; mid < tot; mid <<= 1)
{
int w1 = binpow(3, (mod - 1) / (mid << 1));
if (!~op) w1 = binpow(w1);
for (int i = 0; i < tot; i += mid << 1)
for (int j = 0, k = 1; j < mid; ++j, k = (LL)k * w1 % mod)
{
int p = x[i | j], q = (LL)k * x[i | j | mid] % mod;
x[i | j] = (p + q) % mod, x[i | j | mid] = (p - q) % mod;
}
}
if (~op) return;
int itot = binpow(tot);
for (int i = 0; i < tot; ++i)
x[i] = (LL)x[i] * itot % mod;
}
void PolyInv(int n, int *x, int *g)
{
if (n == 1) return void(g[0] = binpow(x[0]));
int m = n + 1 >> 1;
int bit = 0;
while (1 << bit < n + m + m - 2) ++bit;
int tot = 1 << bit;
PolyInv(m, x, g);
for (int i = m; i < tot; ++i) g[i] = 0;
static int A[N];
for (int i = 0; i < n; ++i) A[i] = x[i];
for (int i = n; i < tot; ++i) A[i] = 0;
ntt(g, bit, 1), ntt(A, bit, 1);
for (int i = 0; i < tot; ++i)
g[i] = (2 - (LL)g[i] * A[i]) % mod * g[i] % mod;
ntt(g, bit, -1);
for (int i = n; i < tot; ++i) g[i] = 0;
}
int main ()
{
static int n, A[N], B[N];
read(n);
for (int i = 0, t = 1; i <= n; t = (LL)t * ++i % mod)
A[i] = (LL)binpow(2, i * (i - 1ll) / 2 % (mod - 1)) * binpow(t) % mod;
PolyInv(n + 1, A, B);
for (int i = 0; i <= n; ++i) B[i] = -B[i];
++B[0];
if (n >= 1) puts("1");
if (n >= 2) puts("-1");
for (int i = 3; i <= n; ++i, puts(""))
write(B[i] ? ((LL)binpow(2, (i - 3ll) * i / 2 % (mod - 1)) * binpow((LL)B[i] * i % mod) % mod + mod) % mod: -1);
return 0;
}