$$\hat{A_x} = \sum_{i\ or\ x = x}{ A_i }$$

$$B0 = A0 \\ B1 = A0 + A1$$

$$\hat{C_c} \\ = \sum{[x\ or\ c=c]C_x} \\ = \sum{[(a\ or\ b)\ or\ c = c]A_a B_b} \\= \sum{[(a\ or\ c = c)]A_a [(b\ or\ c = c)B_b ]} \\=\hat{A_c} \hat{B_c}$$

$$C_x = \sum_{a\ and\ b = x}{A_a B_b}$$

$$([f(a,c)=0]-[f(a,c)=1])([f(b,c)=0] - [f(b,c)=1]) \\= [f(a \oplus b,c) = 0] - [f(a \oplus b,c) = 1]$$

$$B00 = A00 + A11, B01 = A10 + A01 \\ B10 = A10 + A01, B11 = A00 + A11 \\ B0 = A00+A11-A10-A01 \\ B1 = A10+A01-A00-A11$$

$$B0 = \frac{A0+A1}{\sqrt 2} \\ B1 = \frac{A0-A1}{\sqrt 2}$$

$$H_n = \frac{1}{\sqrt 2}\left( \begin{array}{ccc} H{n-1} & H{n-1} \\ H{n-1} & -H{n-1} \end{array} \right)$$

#include <bits/stdc++.h>
using namespace std;
void W(int a[],int l,int r)
{
if(l==r) return;
int m = (l+r)>>1;
W(a,l,m);
W(a,m+1,r);
for(int i=l;i<=m;i++)
{
a[i]-=a[i-l+1+m];
a[i-l+1+m] = -a[i];
}
}
void FWT(int a[],int l,int r)
{
if(l==r) return;
int m = (l+r)>>1;
FWT(a,l,m);
FWT(a,m+1,r);
for(int i=l;i<=m;i++)
{
int x = a[i], y = a[i-l+1+m];
a[i] = x+y;
a[i-l+1+m] = x-y;
}
}
void rFWT(int a[],int l,int r)
{
if(l==r) return;
int m = (l+r)>>1;
for(int i=l;i<=m;i++)
{
int x = a[i], y = a[i-l+1+m];
a[i] = (x+y)/2;
a[i-l+1+m] = (x-y)/2;
}
rFWT(a,l,m);
rFWT(a,m+1,r);
}
int sol(int now)
{
int ans = 1;
for(;now;now>>=1) if(now&1) ans=-ans;
return ans;
}
#define N 100010
int a[N],s[N];
int main()
{
int t;
cin >> t;
for(int i=0;i<(1<<t);i++) scanf("%d",&a[i]);
for(int i=0;i<(1<<t);i++)
{
s[i] = 0;
for(int j=0;j<(1<<t);j++) s[i] += sol(i^j)*a[j];
}
W(a,0,(1<<t)-1);
for(int i=0;i<(1<<t);i++) cout << s[i] - a[i] << endl;
return 0;
}
View Code

posted @ 2018-07-10 10:21  lawyer'  阅读(201)  评论(0编辑  收藏  举报