# bzoj3771: Triple（容斥+生成函数+FFT）

$A(x)$为斧头的生成函数，其中第$x^i$项的系数为价值为$i$的斧头个数，那么$A(x)+A^2(x)+A^3(x)$就是答案（于是信心满满的打了一发连样例都没过）

//minamoto
#include<cstdio>
#include<cmath>
#include<algorithm>
#define R register
#define fp(i,a,b) for(R int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(R int i=a,I=b-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
const int N=6e5+5;const double Pi=acos(-1.0);
struct complex{
double x,y;
complex(double xx=0,double yy=0){x=xx,y=yy;}
inline complex operator +(const complex &b)const{return complex(x+b.x,y+b.y);}
inline complex operator -(const complex &b)const{return complex(x-b.x,y-b.y);}
inline complex operator *(const complex &b)const{return complex(x*b.x-y*b.y,x*b.y+y*b.x);}
inline complex operator *(const int &b){return complex(x*b,y*b);}
inline complex operator /(const int &b){return complex(x/b,y/b);}
}A[N],B[N],C[N],O[N],ans[N];
int r[N],lim,n,x,l,m;
void FFT(complex *A,int ty){
fp(i,0,lim-1)if(i<r[i])swap(A[i],A[r[i]]);
for(R int mid=1;mid<lim;mid<<=1){
int I=(mid)<<1;
complex Wn(cos(Pi/mid),ty*sin(Pi/mid));
fp(i,1,mid-1)O[i]=O[i-1]*Wn;
for(R int j=0;j<lim;j+=I)fp(k,0,mid-1){
complex x=A[j+k],y=O[k]*A[j+k+mid];
A[j+k]=x+y,A[j+k+mid]=x-y;
}
}if(ty==-1)fp(i,0,lim-1)A[i].x=(int)(A[i].x/lim+0.5);
}
int main(){
//	freopen("testdata.in","r",stdin);