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
| #include <iostream> #include <cstdio> #include <cstring>
#define MOD 998244353 #define g 3
using namespace std;
typedef long long LL;
const int MAXN = 1e05 + 10;
LL power (LL x, LL p) { LL cnt = 1; while (p) { if (p & 1) cnt = cnt * x % MOD; x = x * x % MOD; p >>= 1; } return cnt; } const LL invg = power (g, MOD - 2);
int oppo[MAXN << 2]= {0}; void DFT (LL* a, int limit, int inv) { for (int i = 0; i < limit; i ++) if (i < oppo[i]) swap (a[i], a[oppo[i]]); for (int mid = 1; mid < limit; mid <<= 1) { LL omega = power (inv == 1 ? g : invg, 1ll * (MOD - 1) / (mid << 1)); for (int n = mid << 1, j = 0; j < limit; j += n) { LL x = 1; for (int k = 0; k < mid; k ++, x = x * omega % MOD) { LL a1 = a[j + k], xa2 = x * a[j + mid + k] % MOD; a[j + k] = (a1 + xa2) % MOD; a[j + mid + k] = (a1 - xa2 + MOD) % MOD; } } } } LL a1[MAXN << 2]= {0}, a2[MAXN << 2]= {0}; void NTT (LL* A, LL* B, int n, int m) { int limit, lim; for (limit = 1, lim = 0; limit < n + m; limit <<= 1, lim ++); for (int i = 0; i < limit; i ++) oppo[i] = (oppo[i >> 1] >> 1) | ((i & 1) << (lim - 1)); for (int i = 0; i < limit; i ++) a1[i] = a2[i] = 0; for (int i = 0; i <= n; i ++) a1[i] = A[i]; for (int i = 0; i <= m; i ++) a2[i] = B[i]; DFT (a1, limit, 1), DFT (a2, limit, 1); for (int i = 0; i < limit; i ++) a1[i] = a1[i] * a2[i] % MOD; DFT (a1, limit, - 1); LL invn = power (limit, MOD - 2); for (int i = 0; i < limit; i ++) A[i] = a1[i] * invn % MOD; } LL temp[MAXN << 2]= {0}; void inverse (int deg, LL* A, LL* B) { if (deg == 1) { B[0] = 1; return ; } inverse ((deg + 1) >> 1, A, B); int n, lim; for (n = 1, lim = 0; n <= (deg << 1); n <<= 1, lim ++); for (int i = 0; i < n; i ++) oppo[i] = (oppo[i >> 1] >> 1) | ((i & 1) << (lim - 1)); for (int i = 0; i < n; i ++) temp[i] = 0; for (int i = 0; i < deg; i ++) temp[i] = A[i]; NTT (temp, B, deg, deg), NTT (temp, B, deg, deg); for (int i = 0; i < deg; i ++) B[i] = (2ll * B[i] % MOD - temp[i] + MOD) % MOD; }
LL fact[MAXN]= {0};
int N; LL F[MAXN << 2]= {0}; LL G[MAXN]= {0}, invG[MAXN << 2]= {0};
LL answer[MAXN]= {0};
int main () { scanf ("%d", & N); fact[0] = 1; for (int i = 1; i <= N; i ++) fact[i] = fact[i - 1] * i % MOD; for (int i = 1; i <= N; i ++) F[i] = G[i] = power (2ll, 1ll * i * (i - 1) >> 1) * power (fact[i], MOD - 2); G[0] ++; inverse (N, G, invG); NTT (F, invG, N, N); for (int i = 1; i <= N; i ++) { if (i == 1) answer[i] = 1; else if (i == 2) answer[i] = - 1; else answer[i] = fact[i - 1] * power (2ll, 1ll * i * (i - 1) / 2ll - i) % MOD * power (F[i] * fact[i] % MOD, MOD - 2) % MOD; } for (int i = 1; i <= N; i ++) printf ("%lld\n", answer[i]);
return 0; }
|