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
| const unsigned long long Mod(998244353); inline void Mn(unsigned& x) {x -= ((x >= Mod) ? Mod : 0);} inline unsigned long long Pow(unsigned long long x, unsigned y) { unsigned long long Rt(1); while (y) {if(y & 1)Rt = Rt * x % Mod; x = x * x % Mod, y >>= 1;} return Rt; } unsigned long long W[20], IW[20]; unsigned a[262150], b[262150], Two[20], m(1), n, Lgn(0); unsigned A, B, C, D, t; unsigned Cnt(0), Ans(0), Tmp(0); inline void DIT(unsigned* f, unsigned Lg, unsigned long long* Curw) { unsigned Len(Two[Lg]); unsigned long long W_i(1); for (unsigned i(1), j(1); i <= Lg; ++i, j <<= 1, W_i = 1) { for (unsigned k(0); k < Len; ++k, W_i = W_i * Curw[i] % Mod) if (!(k & j)) { unsigned long long TmA(f[k]), TmB(f[k | j] * W_i % Mod); f[k] = TmA + TmB, Mn(f[k]); f[k | j] = Mod + TmA - TmB, Mn(f[k | j]); } } } inline void DIF(unsigned* f, unsigned Lg, unsigned long long* Curw) { unsigned Len(Two[Lg]); unsigned long long W_i(1); for (unsigned i(Lg), j(1 << (Lg - 1)); i; --i, j >>= 1, W_i = 1) { for (unsigned k(0); k < Len; ++k, W_i = W_i * Curw[i] % Mod) if (!(k & j)) { unsigned long long TmA(f[k]), TmB(f[k | j]); f[k] = TmA + TmB, Mn(f[k]); f[k | j] = (Mod + TmA - TmB) * W_i % Mod; } } } inline void Multi(unsigned* f, unsigned* g, unsigned* Rt, unsigned Lg) { unsigned Len(Two[Lg]); DIF(f, Lg, W), DIF(g, Lg, W); for (unsigned i(0); i < Len; ++i) Rt[i] = ((unsigned long long)f[i] * g[i] % Mod) * g[i] % Mod; DIT(Rt, Lg, IW); unsigned long long InvLen(Pow(Len, 998244351)); for (unsigned i(0); i < Len; ++i) Rt[i] = Rt[i] * InvLen % Mod; } inline void Inv(unsigned* f, unsigned* Rt, unsigned Lg) { if(Lg == 0) {Rt[0] = Pow(f[0], 998244351); return;} unsigned Len(1 << Lg); unsigned g[Len << 1]; Inv(f, g, Lg - 1), memset(g + (Len >> 1), 0, (Len + (Len << 1)) << 1); memcpy(Rt, f, Len << 2), memset(Rt + Len, 0, Len << 2); Multi(Rt, g, Rt, Lg + 1); unsigned long long InvLen(Pow(1 << (Lg + 1), 998244351)); DIT(g, Lg + 1, IW); for (unsigned i(0); i < Len; ++i) g[i] = g[i] * InvLen % Mod; for (unsigned i(0); i < Len; ++i) Rt[i] = ((g[i] << 1) + Mod - Rt[i]) % Mod; } signed main() { n = RD(), Two[0] = 1; for (unsigned i(1); i < 20; ++i) Two[i] = (Two[i - 1] << 1); while (m < n) m <<= 1, ++Lgn; W[19] = Pow(3, 998244352 >> 19), IW[19] = Pow(W[19], 998244351); for (unsigned i(19); i; --i) W[i - 1] = W[i] * W[i] % Mod; for (unsigned i(19); i; --i) IW[i - 1] = IW[i] * IW[i] % Mod; for (unsigned i(0); i < n; ++i) a[i] = RD(); for (unsigned i(n); i < m; ++i) a[i] = 0; Inv(a, b, Lgn); for (unsigned i(0); i < n; ++i) printf("%u ", b[i]); putchar(0x0A); return Wild_Donkey; }
|