/
abc260h.test.cpp
53 lines (45 loc) · 1.1 KB
/
abc260h.test.cpp
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
#define PROBLEM "https://atcoder.jp/contests/abc260/tasks/abc260_Ex"
#include "my_template.hpp"
#include "other/io.hpp"
#include "mod/modint.hpp"
#include "poly/convolution_all.hpp"
#include "linalg/blackbox/pascal.hpp"
#include "linalg/blackbox/vandermonde.hpp"
using mint = modint998;
void solve() {
LL(N, M);
VEC(int, A, N);
vc<int> CNT(N);
for (auto&& x: A) CNT[x - 1]++;
// 包除ルールの個数 -> ルールの決め方
vvc<mint> polys;
FOR(x, N) {
int n = CNT[x];
if (n <= 1) continue;
vc<mint> f(n);
FOR(i, n) f[i] = C<mint>(n - 1, i) * fact_inv<mint>(n - i);
polys.eb(f);
}
vc<mint> f = convolution_all(polys);
FOR(i, len(f)) f[i] *= fact<mint>(N - i);
f = pascal(f, true, true);
{
mint cf = 1;
for (auto&& x: CNT) cf *= fact<mint>(x);
for (auto&& x: f) x *= cf;
}
int L = max(N, M + 1);
vc<mint> g(N);
FOR(i, len(f)) g[N - 1 - i] = f[i];
g.resize(L);
vc<mint> x(L);
FOR(i, L) x[i] = i;
vc<mint> ANS = vandermonde(g, x, true, false);
ANS.erase(ANS.begin());
ANS.resize(M);
print(ANS);
}
signed main() {
solve();
return 0;
}