和上一题一样的,这不过这个去掉一个就可以,大概是酱紫 ∑(aj-bi)*bi 就好(此处a,b可以和原题不同)
1 #include2 #include 3 #include 4 #include 5 #define LL long long 6 #define pi acos(-1) 7 using namespace std; 8 9 const int N=100005;10 11 struct complex12 {13 double r,i;14 complex (double x=0, double y=0) {r=x; i=y;}15 complex operator + (const complex a) { return complex(r+a.r,i+a.i);}16 complex operator - (const complex a) { return complex(r-a.r,i-a.i);}17 complex operator * (const complex a) { return complex(r*a.r-i*a.i,r*a.i+i*a.r);}18 }a[N<<2],b[N<<2],c1[N<<2],c2[N<<2],c3[N<<2];19 20 int n,len,lem,m,qwq;21 int ans[N],ans1[N],ans2[N],ans3[N],A[N],B[N];22 int rev[N<<2];23 char s1[N],s2[N];24 25 void FFT(complex *a, int f)26 {27 for (int i=0; i i) swap(a[i],a[rev[i]]);28 for (int h=2; h<=n; h<<=1)29 {30 complex wn(cos(2*pi*f/h),sin(2*pi*f/h));31 for (int i=0; i >1); j++,w=w*wn)35 {36 complex x=a[i+j],y=w*a[i+j+(h>>1)];37 a[i+j]=x+y;38 a[i+j+(h>>1)]=x-y;39 }40 }41 }42 if (f==-1) for (int i=0; i >1]>>1)|((i&1)?n>>1:0);55 56 for (int i=0; i