ZJOI2014 力 FFT

#include
#define M 262150
using namespace std;

struct fushu
{
	double r, i;
	fushu(double r_=0,double i_=0)
	{
		r=r_,i=i_;
	}
	fushu operator + (const fushu & a)
	{
		return (fushu){r+a.r,i+a.i};
	}
	fushu operator-(const fushu&a)
	{
		return(fushu){r-a.r,i-a.i};
	}

	fushu operator * (const fushu & a)
	{
		return (fushu){r*a.r-i*a.i,r*a.i+i*a.r};
	}
}wn[M],*ans,tmp[M],a[M],b[M],c[M];

int n,N;
double q[M],WN,o[M],p[M];

inline void init_wn() 
{
	double pi=acos(-1),WN=pi*2/N;
	for(int i=0; i<=N; ++i){
		wn[i]=(fushu){cos(WN*i),sin(WN*i)};
	}
}

inline void rev_wn()
{
	for(int i=0; i<=N; ++i)wn[i].i=-wn[i].i;
}

void fft(int n, int s1 ,int mi)
{
	if(n==1)return;
	int m=n>>1,len=1<=N)N<<=1;

	init_wn();
	ans=a;
	fft(N,0,0);
	ans=b;
	fft(N,0,0);
	for(int i=0; i

你可能感兴趣的:(数论)