## 题目

HDU6057传送门

### 下面是代码

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;

const int P = 998244353 , inv2 = 499122177 ;
int N , ws , a[(1<<20)+5] , b[(1<<20)+5] , c[(1<<20)+5] , popcnt[(1<<20)+5] ;
int A[20][1<<20] , B[20][1<<20] , C[20][1<<20] ;

void FWT( int *a , int lf , int rg , bool rev ){
if( lf == rg ) return ;
int siz = ( rg - lf + 1 ) >> 1 , t0 , t1 ;
FWT( a , lf , lf + siz - 1 , rev ) ;
FWT( a , rg - siz + 1 , rg , rev ) ;
for( int i = lf + siz - 1 ; i >= lf ; i -- ){
t0 = a[i] , t1 = a[i+siz] ;
if( rev ){
a[i] = 1LL * inv2 * ( t0 + t1 ) %P ;
a[i+siz] = 1LL * inv2 * ( t0 - t1 ) %P ;
} else a[i] = ( t0 + t1 )%P , a[i+siz] = ( t0 - t1 )%P ;
}
}

void solve(){
for( int i = 1 ; i < N ; i ++ )
popcnt[i] = popcnt[i-(i&-i)] + 1 ;
for( int i = 0 ; i < N ; i ++ ){
A[ popcnt[i] ][i] = ( 1LL << popcnt[i] ) * a[i] %P ;
B[ popcnt[i] ][i] = b[i] ;
} for( int i = 0 ; i <= ws ; i ++ )
FWT( A[i] , 0 , N - 1 , 0 ) ,
FWT( B[i] , 0 , N - 1 , 0 ) ;

for( int k = 0 ; k <= ws ; k ++ ){
for( int y = k , x = 0 ; y <= ws ; y ++ , x ++ )
for( int i = 0 ; i < N ; i ++ )
C[k][i] = ( C[k][i] + 1LL * A[x][i] * B[y][i] )%P ;
FWT( C[k] , 0 , N - 1 , 1 ) ;
} for( int i = 0 ; i < N ; i ++ ) c[i] = C[ popcnt[i] ][i] ;

long long muls = 1 , ans = 0 ;
for( int i = 0 ; i < N ; i ++ ){
ans = ( ans + c[i] * muls )%P ;
muls = muls * 1526 %P ;
} printf( "%lld\n" , ( ans + P )%P ) ;
}

int main(){
scanf( "%d" , &ws ) ; N = ( 1 << ws ) ;
for( int i = 0 ; i < N ; i ++ ) scanf( "%d" , &a[i] ) ;
for( int i = 0 ; i < N ; i ++ ) scanf( "%d" , &b[i] ) ;
solve() ;
}