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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
| #include <bits/stdc++.h> #include <bits/extc++.h> using namespace std; using namespace __gnu_cxx; using namespace __gnu_pbds; namespace Legendgod { namespace Read {
#ifdef Fread const int Siz = (1 << 21) + 5; char *iS, *iT, buf[Siz]; #define gc() ( iS == iT ? (iT = (iS = buf) + fread(buf, 1, Siz, stdin), iS == iT ? EOF : *iS ++) : *iS ++ ) #define getchar gc #endif template <typename T> void r1(T &x) { x = 0; char c(getchar()); int f(1); for(; !isdigit(c); c = getchar()) if(c == '-') f = -1; for(; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); x *= f; } template <typename T, typename...Args> void r1(T &x, Args&...arg) { r1(x), r1(arg...); } #undef getchar }
using namespace Read;
const int maxn = 1.2e6 + 500; const int mod = 998244353, G = 3, invG = 332748118; int n, m, K;
int ksm(int x,int mi) { int res(1); while(mi) { if(mi & 1) res = 1ll * res * x % mod; mi >>= 1; x = 1ll * x * x % mod; } return res; }
int inv[maxn], w[2][21][maxn]; int Inv(int x) { return x < maxn ? inv[x] : ksm(x, mod - 2); } int lim, len, rev[maxn];
void getrev(int x) { for(lim = 1, len = 0; lim <= x; lim <<= 1, ++ len) ; for(int i = 0; i < lim; ++ i) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (len - 1)); }
void NTT(int *A,int op = 1) { for(int i = 0; i < lim; ++ i) if(i < rev[i]) swap(A[i], A[rev[i]]); for(int mid = 1, ts = 1; mid < lim; mid <<= 1, ++ ts) { for(int j = 0, c = (mid << 1); j < lim; j += c) { const int* w1 = w[op == 1 ? 0 : 1][ts]; for(int k = 0; k < mid; ++ k) { int x = A[j + k], y = 1ll * w1[k] * A[j + k + mid] % mod; A[j + k] = (x + y) % mod; A[j + k + mid] = (x - y + mod) % mod; } } } if(op != 1) { int z = Inv(lim); for(int i = 0; i < lim; ++ i) A[i] = 1ll * A[i] * z % mod; } }
int g[maxn], fac[maxn], finv[maxn];
void init(int x) { fac[0] = 1; for(int i = 1; i <= x; ++ i) fac[i] = 1ll * fac[i - 1] * i % mod; finv[x] = ksm(fac[x], mod - 2); for(int i = x - 1; i >= 0; -- i) finv[i] = 1ll * finv[i + 1] * (i + 1) % mod; for(int i = 1; i < maxn; ++ i) inv[i] = ksm(i, mod - 2); for(int t = 1; t <= 20; ++ t) { int buf0 = ksm(G, (mod - 1) / (1 << t)); int buf1 = ksm(invG, (mod - 1) / (1 << t)); w[0][t][0] = w[1][t][0] = 1; for(int k = 1; k < (1 << t); ++ k) { w[0][t][k] = 1ll * w[0][t][k - 1] * buf0 % mod; w[1][t][k] = 1ll * w[1][t][k - 1] * buf1 % mod; } } } int C(int a,int b) { if(a < b) return 0; return 1ll * fac[a] * finv[b] % mod * finv[a - b] % mod; } int sign(int x) { return (x & 1) ? mod - 1 : 1; } #define cpy(a, b, c) memcpy(a, b, sizeof(int) * (c)) #define clr(a, b) memset(a, 0, sizeof(int) * (b)) void Solve(int l,int r) { if(l == r) { g[l] = 1ll * g[l] * Inv(n - l + 1) % mod; return ; } int mid = (l + r) >> 1, ln = mid - l + r - l + 2; Solve(l, mid); getrev(ln); static int s1[maxn], s2[maxn], s3[maxn], s4[maxn], ans[maxn]; clr(s1, lim), clr(s2, lim), clr(s3, lim), clr(s4, lim), clr(ans, lim); for(int i = 0; i <= mid - l; ++ i) { s1[i] = 1ll * g[i + l] * (n - m) % mod; s2[i] = 1ll * g[i + l] * (i + l) % mod; } for(int i = 0; i <= r - l; ++ i) { s3[i] = 1ll * sign(i) * finv[i] % mod; s4[i] = 1ll * sign(i + 1) * finv[i + 1] % mod; } if(r - l <= 100 || mid - l <= 50) { for(int sr = mid + 1 - l; sr <= r - l; ++ sr) for(int sl = 0; sl <= mid - l && sl <= sr; ++ sl) { ans[sr] = (ans[sr] + 1ll * s1[sl] * s3[sr - sl] % mod + 1ll * s2[sl] * s4[sr - sl] % mod) % mod; } } else { NTT(s1), NTT(s2), NTT(s3), NTT(s4); for(int i = 0; i < lim; ++ i) ans[i] = (1ll * s1[i] * s3[i] % mod + 1ll * s2[i] * s4[i] % mod) % mod; NTT(ans, -1); } for(int i = mid + 1; i <= r; ++ i) g[i] = (g[i] - ans[i - l] + mod) % mod; Solve(mid + 1, r);
}
void Inv(int *A, int* B, int ln) { if(ln == 1) return B[0] = Inv(A[0]), void(); static int s1[maxn]; Inv(A, B, (ln + 1) >> 1);
getrev(ln << 1); cpy(s1, A, ln), clr(s1 + ln, lim); NTT(s1), NTT(B); for(int i = 0; i < lim; ++ i) B[i] = 1ll * B[i] * (2 - 1ll * s1[i] * B[i] % mod + mod) % mod; NTT(B, -1); for(int i = ln; i < lim; ++ i) B[i] = 0; }
int P[maxn], Q[maxn], B[maxn], rs[maxn], F[maxn], T[maxn], sA[maxn], ans[maxn];
void Mul(int* A,int* B,int* as,int ln) { getrev(ln << 1); static int a[maxn], b[maxn]; clr(a, lim), clr(b, lim); cpy(a, A, ln), cpy(b, B, ln); NTT(a), NTT(b); for(int i = 0; i < lim; ++ i) as[i] = 1ll * a[i] * b[i] % mod; NTT(as, -1); }
signed main() { int i, j; r1(n, m, K); int n1 = K - 1, n2 = n - K; init(n + 5); g[0] = 1ll * sign(m) * C(n + 1, m) % mod * (n - m + 1) % mod; Solve(0, n - 1);
getrev(n); for(i = 0; i <= n; ++ i) B[i] = finv[i + 1]; Inv(B, rs, n + 1), cpy(B, rs, n + 1);
for(i = 0; i < n; ++ i) Q[n - i - 1] = 1ll * g[n - i - 1] * sign(n2) % mod * C(i, n2) % mod;
Mul(Q, B, Q, n); for(i = 0; i < n; ++ i) P[n - i - 1] = 1ll * g[n - i - 1] * sign(n1 - i) % mod * C(i, n1) % mod; Mul(P, B, P, n); for(i = 0; i < n; ++ i) F[i] = 1ll * (Q[n - i - 1] - P[n - i - 1] + mod) * finv[i] % mod; for(i = n; i >= 1; -- i) F[i] = 1ll * F[i - 1] * Inv(i) % mod; F[0] = 0;
for(i = 0; i < n; ++ i) F[i] = 1ll * F[i] * fac[n - i - 1] % mod; for(i = 0; i < n; ++ i) T[i] = finv[i]; Mul(F, T, sA, n); for(i = 0; i < n; ++ i) ans[i] = 1ll * sA[i] * fac[i] % mod;
int left = 0; for(i = 0; i <= m; ++ i) left = (left + 1ll * C(n + 1, i) * ksm(m + 1 - i, n) % mod * sign(i) % mod) % mod;
for(i = 0; i < n; ++ i) left = (left - ans[i] + mod) % mod; left = 1ll * left * Inv(n) % mod; for(i = 0; i < n; ++ i) ans[i] = (ans[i] + left) % mod;
for(i = 0; i < n; ++ i) printf("%d ", ans[i]); puts(""); return 0; }
}
signed main() { return Legendgod::main(), 0; }
|