提交时间:2025-06-08 16:26:45
运行 ID: 38008
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define mk make_pair #define fi first #define se second using namespace std; const int N=1e6; int n,m,k; ll a[N],pw[10]; ll t1[N],t2[N]; int main(){ cin>>n>>k;m=powl(k+1,n); for(int i=0;i<m;i++) cin>>a[i]; pw[0]=1;for(int i=1;i<=n;i++) pw[i]=pw[i-1]*(k+1); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if((j/pw[i])%(k+1)!=0) continue; for(int x=0;x<=k;x++) t1[x]=a[j+pw[i]*x]; //for(int x=0;x<=k;x++) cout<<t1[x]<<' ';cout<<endl; if(k==3){ t2[0]=t1[0]-t1[2]+t1[3]; t2[1]=t1[2]-t1[3]; t2[2]=t1[1]-t1[0]; t2[3]=t1[3]-t1[1]+t1[0]; }else if(k==5){ t2[0]=t1[1]+t1[4]-t1[2]-t1[5]; t2[1]=t1[2]+t1[5]+t1[0]-t1[1]-t1[4]; t2[2]=t1[1]-t1[0]; t2[3]=t1[4]-t1[5]; t2[4]=t1[3]+t1[5]+t1[0]-t1[1]-t1[4]; t2[5]=t1[1]+t1[4]-t1[3]-t1[0]; }else{ t2[0]=t1[0]+t1[3]+t1[6]-t1[2]-t1[5]; t2[1]=t1[2]+t1[5]-t1[6]-t1[3]; t2[2]=t1[1]-t1[0]; t2[3]=t1[3]+t1[0]+t1[6]-t1[1]-t1[5]; t2[4]=t1[5]-t1[6]; t2[5]=t1[4]+t1[1]-t1[0]-t1[3]; t2[6]=t1[0]+t1[3]+t1[6]-t1[1]-t1[4]; } for(int x=0;x<=k;x++) a[j+pw[i]*x]=t2[x]; }//for(int j=0;j<m;j++) cout<<a[j]<<' ';cout<<endl; }for(int i=0;i<m;i++) cout<<a[i]<<' ';cout<<endl; return 0; }