# 题目大意

$n\le 10^5$

# 思路

$g_n=\sum_{i=1}^{n} \binom{n}{i}2^{i(n-i)}g_{n-i}(-1)^{i-1}$

$g_n=\sum_{i=1}^{n} \binom{n}{i}\frac{(\sqrt{2})^{n^2}}{(\sqrt{2})^{i^2}(\sqrt{2})^{(n-i)^2}}g_{n-i}(-1)^{i-1}$

$\sqrt{2}\equiv 116195171\pmod {998244353}$

$G(x)=\sum_{i=0}^{n} \frac{g_i}{(\sqrt{2})^{i^2}i!}x^i$

$H(x)=\sum_{i=1}^{n} \frac{(-1)^{i-1}}{(\sqrt{2})^{i^2}i!}x^i$

$G(x)=G(x)H(x)+1$

$G(x)=\frac{1}{1-H(x)}$

$\ln F(x)$

# $\text {Code}$

#include <bits/stdc++.h>
using namespace std;

#define SZ(x) ((int)x.size())
#define Int register int
#define sqr2 116195171
#define mod 998244353
#define MAXN 1000005

int mul (int a,int b){return 1ll * a * b % mod;}
int dec (int a,int b){return a >= b ? a - b : a + mod - b;}
int add (int a,int b){return a + b >= mod ? a + b - mod : a + b;}
int qkpow (int a,int k){
int res = 1;for (;k;k >>= 1,a = 1ll * a * a % mod) if (k & 1) res = 1ll * res * a % mod;
return res;
}
int inv (int x){return qkpow (x,mod - 2);}

typedef vector <int> poly;

int rev[MAXN];

void ntt (poly &f,int lim,int type){
#define G 3
#define Gi 332748118
int l = log2 (lim);
for (Int i = 0;i < lim;++ i) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << l - 1);
for (Int i = 0;i < lim;++ i) if (i < rev[i]) swap (f[i],f[rev[i]]);
for (Int i = 1;i < lim;i <<= 1){
int Wn = qkpow (type == 1 ? G : Gi,(mod - 1) / (i << 1));
for (Int j = 0;j < lim;j += i << 1)
for (Int k = 0,w = 1;k < i;++ k,w = 1ll * w * Wn % mod){
int x = f[j + k],y = 1ll * w * f[i + j + k] % mod;
f[j + k] = (x + y) % mod,f[i + j + k] = (x + mod - y) % mod;
}
}
if (type == 1) return ;
for (Int i = 0,Inv = inv (lim);i < lim;++ i) f[i] = 1ll * f[i] * Inv % mod;
#undef G
#undef Gi
}

poly operator + (poly a,poly b){
a.resize (max (SZ (a),SZ (b)));
for (Int i = 0;i < SZ (b);++ i) a[i] = add (a[i],b[i]);
return a;
}

poly operator - (poly a,poly b){
a.resize (max (SZ (a),SZ (b)));
for (Int i = 0;i < SZ (b);++ i) a[i] = dec (a[i],b[i]);
return a;
}

poly operator * (poly a,int b){
for (Int i = 0;i < SZ (a);++ i) a[i] = mul (a[i],b);
return a;
}

poly operator * (poly a,poly b){
int d = SZ (a) + SZ (b) - 1,lim = 1;while (lim < d) lim <<= 1;
a.resize (lim),b.resize (lim);
ntt (a,lim,1),ntt (b,lim,1);
for (Int i = 0;i < lim;++ i) a[i] = mul (a[i],b[i]);
ntt (a,lim,-1),a.resize (d);
return a;
}

poly operator << (poly a,int n){
a.resize (SZ (a) + n);
for (Int i = SZ (a) - 1;~i;-- i) a[i] = (i >= n ? a[i - n] : 0);
return a;
}

poly inv (poly a,int n){
poly b(1,inv (a[0])),c;
for (Int l = 4;(l >> 2) < n;l <<= 1){
c.resize (l >> 1);
for (Int i = 0;i < (l >> 1);++ i) c[i] = i < n ? a[i] : 0;
c.resize (l),b.resize (l);
ntt (c,l,1),ntt (b,l,1);
for (Int i = 0;i < l;++ i) b[i] = mul (b[i],dec (2,mul (b[i],c[i])));
ntt (b,l,-1),b.resize (l >> 1);
}
b.resize (n);
return b;
}

poly inv (poly a){return inv (a,SZ (a));}
poly der (poly a){
for (Int i = 0;i < SZ (a) - 1;++ i) a[i] = mul (a[i + 1],i + 1);
a.pop_back ();return a;
}
poly ine (poly a){
a.push_back (0);
for (Int i = SZ (a) - 1;i;-- i) a[i] = mul (a[i - 1],inv (i));
a[0] = 0;return a;
}

poly ln (poly a,int n){
a = ine (der (a) * inv (a));
a.resize (n);
return a;
}
poly ln (poly a){return ln (a,SZ (a));}

poly exp (poly a,int n){
poly b (1,1),c;
for (Int l = 2;(l >> 1) < n;l <<= 1){
b.resize (l),c = ln (b);
for (Int i = 0;i < l;++ i) c[i] = dec (i < n ? a[i] : 0,c[i]);
b = b * c,b.resize (l);
}
b.resize (n);
return b;
}
poly exp (poly a){return exp (a,SZ (a));}

template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}

poly H;
int n,fac[MAXN],ifac[MAXN];

signed main(){
fac[0] = 1;for (Int i = 1;i <= n;++ i) fac[i] = mul (fac[i - 1],i);
ifac[n] = inv (fac[n]);for (Int i = n;i;-- i) ifac[i - 1] = mul (ifac[i],i);
H.resize (n + 1);for (Int i = 1;i <= n;++ i) H[i] = inv (mul (fac[i],qkpow (sqr2,1ll * i * i % (mod - 1)))),H[i] = i & 1 ? mod - H[i] : H[i];
H[0] = 1,H = inv (H);for (Int i = 0;i <= n;++ i) H[i] = mul (H[i],qkpow (sqr2,1ll * i * i % (mod - 1)));H = ln (H);
for (Int i = 1;i <= n;++ i) write (mul (H[i],fac[i])),putchar ('\n');
return 0;
}


# 一个小小的总结

posted @ 2020-07-13 19:12  Dark_Romance  阅读(13)  评论(0编辑  收藏