根据题目描述根据泰勒展开,有:
然后我们尝试瞪出这个东西的组合意义为:若 为子集 的方案数,那么 为把 划分为任意个子集的方案数。
定义 , 为 , 为 。
根据组合意义,我们有 。
定义 为 的二进制下最低位。特别的,我们钦定 。
对于 ,考虑枚举其中一个点所在的子集,则有如下式子。
容易发现这是一个半在线的子集卷积,可以直接用类似集合幂级数求逆的方法,枚举 计算答案,但是这个题有个问题,需要保证 。
考虑魔改一下 fwt,定义 ,。
类似正常的或卷积,我们发现有如下式子:
容易发现这正是我们想要的东西,于是拿这个魔改的卷积拼上一个半在线的子集卷积就行了,时间复杂度 。
Code
#include<bits/stdc++.h>
namespace fast_IO{
#define IOSIZE 100000
char ibuf[IOSIZE], obuf[IOSIZE], *p1 = ibuf, *p2 = ibuf, *p3 = obuf;
#define getchar() ((p1==p2)and(p2=(p1=ibuf)+fread(ibuf,1,IOSIZE,stdin),p1==p2)?(EOF):(*p1++))
#define putchar(x) ((p3==obuf+IOSIZE)&&(fwrite(obuf,p3-obuf,1,stdout),p3=obuf),*p3++=x)
#define isdigit(ch) (ch>47&&ch<58)
#define isspace(ch) (ch<33)
template<typename T> inline T read() { T s = 0; int w = 1; char ch; while (ch = getchar(), !isdigit(ch) and (ch != EOF)) if (ch == '-') w = -1; if (ch == EOF) return false; while (isdigit(ch)) s = s * 10 + ch - 48, ch = getchar(); return s * w; }
template<typename T> inline bool read(T &s) { s = 0; int w = 1; char ch; while (ch = getchar(), !isdigit(ch) and (ch != EOF)) if (ch == '-') w = -1; if (ch == EOF) return false; while (isdigit(ch)) s = s * 10 + ch - 48, ch = getchar(); return s *= w, true; }
template<typename T> inline void print(T x) { if (x < 0) putchar('-'), x = -x; if (x > 9) print(x / 10); putchar(x % 10 + 48); }
inline bool read(char &s) { while (s = getchar(), isspace(s)); return true; }
inline bool read(char *s) { char ch; while (ch = getchar(), isspace(ch)); if (ch == EOF) return false; while (!isspace(ch)) *s++ = ch, ch = getchar(); *s = '\000'; return true; }
inline void print(char x) { putchar(x); }
inline void print(char *x) { while (*x) putchar(*x++); }
inline void print(const char *x) { for (int i = 0; x[i]; i++) putchar(x[i]); }
inline bool read(std::string& s) { s = ""; char ch; while (ch = getchar(), isspace(ch)); if (ch == EOF) return false; while (!isspace(ch)) s += ch, ch = getchar(); return true; }
inline void print(std::string x) { for (int i = 0, n = x.size(); i < n; i++) putchar(x[i]); }
inline bool read(bool &b) { char ch; while(ch=getchar(), isspace(ch)); b=ch^48; return true; }
inline void print(bool b) { putchar(b+48); }
template<typename T, typename... T1> inline int read(T& a, T1&... other) { return read(a) + read(other...); }
template<typename T, typename... T1> inline void print(T a, T1... other) { print(a), print(other...); }
struct Fast_IO { ~Fast_IO() { fwrite(obuf, p3 - obuf, 1, stdout); } } io;
template<typename T> Fast_IO& operator >> (Fast_IO &io, T &b) { return read(b), io; }
template<typename T> Fast_IO& operator << (Fast_IO &io, T b) { return print(b), io; }
#define cout io
#define cin io
}using namespace fast_IO;
using namespace std;
#define int unsigned long long
int n,limit;
vector<int>f[21],g[21];
#define lowbit(x) ((x)&(-x))
#define pop __builtin_popcount
inline void OR(int limit,vector<int>&a,int opt){
for(int len=2;len<=limit;len<<=1)
for(int i=0;i<limit;i+=len)
for(int j=i;j<i+(len>>1);++j)
a[j+(len>>1)]=a[j+(len>>1)]+a[j]*opt;
}
inline void OR_low(int limit,vector<int>&a,int opt){
for(int len=2;len<=limit;len<<=1)
for(int i=0;i<limit;i+=len)
for(int j=i+1;j<i+(len>>1);++j)
a[j+(len>>1)]=a[j+(len>>1)]+a[j]*opt;
}
signed main(){
cin>>n;
limit=(1<<n);
for(int i=0;i<=n;++i)f[i].resize(limit),g[i].resize(limit);
for(int i=0;i<limit;++i)cin>>f[pop(i)][i];
for(int i=0;i<=n;++i)OR_low(limit,f[i],1);
g[0][0]=1;
OR(limit,g[0],1);
for(int i=1;i<=n;++i){
for(int j=0;j<i;++j)
for(int s=0;s<limit;++s)
g[i][s]=g[i][s]+f[j][s]*g[i-j][s];
OR_low(limit,g[i],-1);
for(int s=0;s<limit;++s){
if(pop(s)==i)g[i][s]=f[i][s]+g[i][s];
else g[i][s]=0;
}
OR(limit,g[i],1);
}
for(int i=0;i<limit;++i)cout<<g[pop(i)][i]<<" ";
cout<<"\n";
return 0;
}