#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include using namespace std; using ll = long long; const ll INF = 1ll << 60; #define REP(i,n) for(ll i=0; i using V = vector; template void chmax(A& l, const B& r){ if(l < r) l = r; } template void chmin(A& l, const B& r){ if(r < l) l = r; } #include #include namespace nachia{ // ax + by = gcd(a,b) // return ( x, - ) std::pair ExtGcd(long long a, long long b){ long long x = 1, y = 0; while(b){ long long u = a / b; std::swap(a-=b*u, b); std::swap(x-=y*u, y); } return std::make_pair(x, a); } } // namespace nachia namespace nachia{ template struct StaticModint{ private: using u64 = unsigned long long; unsigned int x; public: using my_type = StaticModint; template< class Elem > static Elem safe_mod(Elem x){ if(x < 0){ if(0 <= x+MOD) return x + MOD; return MOD - ((-(x+MOD)-1) % MOD + 1); } return x % MOD; } StaticModint() : x(0){} StaticModint(const my_type& a) : x(a.x){} StaticModint& operator=(const my_type&) = default; template< class Elem > StaticModint(Elem v) : x(safe_mod(v)){} unsigned int operator*() const { return x; } my_type& operator+=(const my_type& r) { auto t = x + r.x; if(t >= MOD) t -= MOD; x = t; return *this; } my_type operator+(const my_type& r) const { my_type res = *this; return res += r; } my_type& operator-=(const my_type& r) { auto t = x + MOD - r.x; if(t >= MOD) t -= MOD; x = t; return *this; } my_type operator-(const my_type& r) const { my_type res = *this; return res -= r; } my_type operator-() const noexcept { my_type res = *this; res.x = ((res.x == 0) ? 0 : (MOD - res.x)); return res; } my_type& operator*=(const my_type& r){ x = (u64)x * r.x % MOD; return *this; } my_type operator*(const my_type& r) const { my_type res = *this; return res *= r; } bool operator==(const my_type& r) const { return x == r.x; } my_type pow(unsigned long long i) const { my_type a = *this, res = 1; while(i){ if(i & 1){ res *= a; } a *= a; i >>= 1; } return res; } my_type inv() const { return my_type(ExtGcd(x, MOD).first); } unsigned int val() const { return x; } int hval() const { return int(x > MOD/2 ? x - MOD : x); } static constexpr unsigned int mod() { return MOD; } static my_type raw(unsigned int val) { auto res = my_type(); res.x = val; return res; } my_type& operator/=(const my_type& r){ return operator*=(r.inv()); } my_type operator/(const my_type& r) const { return operator*(r.inv()); } }; } // namespace nachia using Mint = nachia::StaticModint<998244353>; namespace nachia{ template struct PrimitiveRoot{ using u64 = unsigned long long; static constexpr u64 powm(u64 a, u64 i) { u64 res = 1, aa = a; for( ; i; i /= 2){ if(i & 1) res = res * aa % MOD; aa = aa * aa % MOD; } return res; } static constexpr bool ExamineVal(unsigned int g){ u64 t = MOD - 1; for(u64 d=2; d*d<=t; d+=1+(d&1)) if(t % d == 0){ if(powm(g, (MOD - 1) / d) == 1) return false; while(t % d == 0) t /= d; } if(t != 1) if(powm(g, (MOD - 1) / t) == 1) return false; return true; } static constexpr unsigned int GetVal(){ for(u64 x=2; x> 1) & (~0ull/3)); c = (c & (~0ull/5)) + ((c >> 2) & (~0ull/5)); c = (c & (~0ull/17)) + ((c >> 4) & (~0ull/17)); c = (c * (~0ull/257)) >> 56; return c; #endif } // please ensure x != 0 int MsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return 63 - __builtin_clzll(x); #else using u64 = unsigned long long; int q = (x >> 32) ? 32 : 0; auto m = x >> q; constexpr u64 hi = 0x88888888; constexpr u64 mi = 0x11111111; m = (((m | ~(hi - (m & ~hi))) & hi) * mi) >> 35; m = (((m | ~(hi - (m & ~hi))) & hi) * mi) >> 31; q += (m & 0xf) << 2; q += 0x3333333322221100 >> (((x >> q) & 0xf) << 2) & 0xf; return q; #endif } // please ensure x != 0 int LsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return __builtin_ctzll(x); #else return MsbIndex(x & -x); #endif } } namespace nachia { template struct NttInterface{ template void Butterfly(Iter, int) const {} template void IButterfly(Iter, int) const {} template void BitReversal(Iter a, int N) const { for(int i=0, j=0; j>1; k > (i^=k); k>>=1); } } }; } // namespace nachia #include #include namespace nachia{ template struct Ntt : NttInterface { using u32 = unsigned int; using u64 = unsigned long long; static int ceil_pow2(int n) { int x = 0; while ((1U << x) < (u32)(n)) x++; return x; } static constexpr int bsf_constexpr(unsigned int n) { int x = 0; while (!(n & (1 << x))) x++; return x; } struct fft_info { static constexpr u32 g = nachia::PrimitiveRoot::val; static constexpr int rank2 = bsf_constexpr(mint::mod()-1); using RootTable = std::array; RootTable root, iroot, rate3, irate3; fft_info(){ root[rank2] = mint(g).pow((mint::mod() - 1) >> rank2); iroot[rank2] = root[rank2].inv(); for(int i=rank2-1; i>=0; i--){ root[i] = root[i+1] * root[i+1]; iroot[i] = iroot[i+1] * iroot[i+1]; } mint prod = 1, iprod = 1; for(int i=0; i<=rank2-3; i++){ rate3[i] = root[i+3] * prod; irate3[i] = iroot[i+3] * iprod; prod *= iroot[i+3]; iprod *= root[i+3]; } } }; template void ButterflyLayered(RandomAccessIterator a, int n, int stride, int repeat) const { static const fft_info info; int h = n * stride; while(repeat--){ int len = 1; int p = h; if(ceil_pow2(n)%2 == 1){ p >>= 1; for(int i=0; i stride; ){ p >>= 2; mint rot = 1, imag = info.root[2]; u64 mod2 = u64(mint::mod()) * mint::mod(); int offset = p; for(int s=0; s void Butterfly(RandomAccessIterator a, int n) const { ButterflyLayered(a, n, 1, 1); } template void IButterflyLayered(RandomAccessIterator a, int n, int stride, int repeat) const { static const fft_info info; constexpr int MOD = mint::mod(); while(repeat--){ int len = n; int p = stride; for( ; 2 < len; ){ len >>= 2; mint irot = 1, iimag = info.iroot[2]; int offset = p; for(int s=0; s void IButterfly(RandomAccessIterator a, int n) const { IButterflyLayered(a, n, 1, 1); } }; } // namespace nachia namespace nachia{ template std::vector Convolution( const std::vector& A, const std::vector& B ){ int n = A.size(); int m = B.size(); if(n <= 40 || m <= 40){ if(n+m == 0) return std::vector(0); std::vector C(n+m-1); for(int i=0; i C(g); for(int i=0; i ntt; ntt.Butterfly(C.begin(), g); std::vector D(g); for(int i=0; i std::vector WeightedPowerSum(std::vector A, std::vector X, int M){ auto invFps = [](std::vector B, int n){ Modint b = B[0].inv(); for(auto& a : B) a *= b; std::vector res = {1}; int z = 1; while(z < n){ std::vector T(z*2); for(int i=1; i, std::vector>> fracs(A.size()*2); for(std::size_t i=0; i{ A[i] }; fracs[i].second = std::vector{ 1, -X[i] }; } std::size_t l = 0; std::size_t r = A.size(); while(l + 1 != r){ fracs[r].second = Convolution(fracs[l].second, fracs[l+1].second); auto a = Convolution(fracs[l].first, fracs[l+1].second); auto b = Convolution(fracs[l].second, fracs[l+1].first); if(a.size() < b.size()) std::swap(a,b); for(std::size_t i=0; i std::vector WeightedExpAxSum(std::vector W, std::vector A, int M){ if(M == 0) return std::vector(); auto buf = WeightedPowerSum(std::move(W), std::move(A), M); std::vector fact(M); fact[0] = Modint(1); for(int i=1; i=0; i--){ buf[i] *= f; f += Modint(i); } return fact; } // x <- e^x template std::vector SubstituteExpX(std::vector F, int M){ std::vector x(M); for(int i=0; i> N >> M; V A(N); REP(i,N){ ll a; cin >> a; A[i] = a; } auto B = nachia::WeightedPowerSum(V(N,1), A, M+1); V mobius(M+1); mobius[1] = 1; for(ll p=1; p<=M; p++) for(ll q=2; p*q<=M; q++) mobius[p*q] -= mobius[p]; V X(M+1); for(ll p=1; p<=M; p++) for(ll q=1; p*q<=M; q++){ X[p*q] += mobius[p] * B[p].pow(q); } REP(i,M){ if(i) cout << " "; cout << X[i+1].val(); } cout << "\n"; } int main(){ cin.tie(0)->sync_with_stdio(0); testcase(); return 0; }