P12232
集合幂级数求逆的模板。
由于 :
显然,,否则:
直接做子集卷积即可,详见代码。
代码
#include<bits/stdc++.h>
using namespace std;
#define gt __builtin_popcount
#define ll long long
const int N=1<<20,P=998244353;
int n,m,t,a[N],F[21][N],G[21][N];
ll qpow(ll a,int b){
ll s=1;
while(b){
if(b&1)s=s*a%P;
a=a*a%P,b/=2;
}
return s;
}
inline void fwt(int*f,int op){
for(int l=1;l<m;l<<=1){
for(int p=0;p<m;p+=l<<1){
for(int i=p;i<p+l;i++){
f[i+l]=(f[i]*op+f[i+l])%P;
}
}
}
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n;
m=1<<n;
for(int i=0;i<m;i++){
cin>>a[i];
F[gt(i)][i]=a[i];
}
for(int i=0;i<=n;i++)fwt(F[i],1);
G[0][0]=t=qpow(a[0],P-2);
fwt(G[0],1);
for(int i=1;i<=n;i++){
for(int j=0;j<i;j++){
for(int s=0;s<m;s++){
G[i][s]=(G[i][s]-1ll*F[i-j][s]*G[j][s])%P;
}
}
for(int s=0;s<m;s++)G[i][s]=1ll*G[i][s]*t%P;
}
for(int i=0;i<=n;i++)fwt(G[i],-1);
for(int i=0;i<m;i++)cout<<(G[gt(i)][i]+P)%P<<' ';
}