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
| #include"bits/stdc++.h" #define re register #define int long long using namespace std; const int maxn=(1<<17)+10,mod=998244353,inv2=499122177; int n,S; int A[maxn],B[maxn]; int a[maxn],b[maxn],c[maxn]; inline void in(){for(re int i=0;i<=S;++i) a[i]=A[i],b[i]=B[i];} inline void get(){for(re int i=0;i<=S;++i) c[i]=a[i]*b[i]%mod;} inline void out(){for(re int i=0;i<=S;++i) cout<<c[i]<<" ";cout<<'\n';} inline void OR(int f[],int op){ for(re int i=0;i<n;++i){ for(re int s=0;s<=S;++s){ if((s>>i)&1) f[s]=((f[s]+f[s^(1<<i)]*op)%mod+mod)%mod; } } } inline void AND(int f[],int op){ for(re int i=0;i<n;++i){ for(re int s=0;s<=S;++s){ if((s>>i)&1) f[s^(1<<i)]=((f[s^(1<<i)]+f[s]*op)%mod+mod)%mod; } } } inline void XOR(int f[],int op){ for(re int i=0,len=1;i<n;++i,len<<=1){ for(re int s=0;s<=S;s+=len*2){ for(re int j=0;j<len;++j){ f[s+j]=(f[s+j]+f[s+j+len])%mod; f[s+j+len]=((f[s+j]-f[s+j+len]*2)%mod+mod)%mod; f[s+j]=((f[s+j]*op)%mod+mod)%mod; f[s+j+len]=((f[s+j+len]*op)%mod+mod)%mod; } } } } signed main(){ #ifndef ONLINE_JUDGE freopen("1.in","r",stdin); freopen("1.out","w",stdout); #endif ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n;S=(1<<n)-1; for(re int i=0;i<=S;++i) cin>>A[i]; for(re int i=0;i<=S;++i) cin>>B[i]; in(),OR(a,1),OR(b,1),get(),OR(c,-1),out(); in(),AND(a,1),AND(b,1),get(),AND(c,-1),out(); in(),XOR(a,1),XOR(b,1),get(),XOR(c,inv2),out(); return 0; }
|