题目链接:https://codeforces.com/contest/914/problem/G
子集卷积+FWT的板子题,记一个子集卷积的板子
代码:
#include
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair pii;
const int MOD=1e9+7;
const int INV2=MOD-MOD/2;
const int MAXN=1e6+5;
const int M=(1<<17)+5;
int s[MAXN],f[MAXN],g[18][M],h[18][M],d[MAXN];
int A[M],B[M],C[M],D[M],cnt[M];
void FMT(int *A,int o)
{
for(int i=1;i<(1<<17);i<<=1)
for(int j=0;j<(1<<17);j++)
if(i&j) (A[j]+=A[j^i]*o)%=MOD;
}
void FWT(int a[],int n,int op)
{
for(int d=1;d