Title: http://www.lydsy.com/JudgeOnline/problem.php?id=3160
I'm a silly smile face
1#include <bits/stdc++.h>2 #defineINF 10000000003 #definell Long Long4 #defineN 2000055 #defineMoD 10000000076 using namespacestd;7 intRead () {8 intx=0, f=1;CharCh=GetChar ();9 while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}Ten while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} One returnx*F; A } - structcd{ - Doublex, y; theCD (DoubleA=0,Doubleb=0) {x=a;y=b;} -Friend CDoperator+ (CD n1,cd n2) {returnCD (n1.x+n2.x,n1.y+n2.y);} -Friend CDoperator-(CD n1,cd n2) {returnCD (n1.x-n2.x,n1.y-n2.y);} -Friend CDoperator* (CD n1,cd n2) {returnCD (n1.x*n2.x-n1.y*n2.y,n1.x*n2.y+n1.y*n2.x);} + }; - Const DoublePi=acos (-1.0); + intbit,n,nn,ans,m,mx,id,p[n<<1]; A Chars[n],st[n<<1]; atCD a[n<<1],b[n<<1]; - voidFFT (CD *a,intNinttype) { - for(intI=0, j=0; i<n;i++) { - if(j>i) swap (a[i],a[j]); - intk=N; - while(j& (k >>=1)) j&=~K; inj|=K; - } to for(intI=1; i<=bit;i++){ +CD w_n (cos (2*type*pi/(1<<i)), Sin (2*type*pi/(1<<i))); - for(intj=0; j<n;j+= (1<<i)) { theCD W (1,0); * for(intk=j;k<j+ (1<< (I-1)); k++){ $CD tmp=a[k],tt=w*a[k+ (1<< (I-1))];Panax Notoginsenga[k]=tmp+tt; -a[k+ (1<< (I-1))]=tmp-tt; thew=w*W_n; + } A } the } + if(type<0) for(intI=0; i<n;i++) a[i].x/=N; - } $ intMain () { $scanf"%s", s); -N=strlen (s); nn=N; -bit=1; the while((1<<bit) < (n<<1)) bit++; -n=1<<bit;Wuyi for(inti=nn;i<n;i++) A[I]=B[I]=CD (0,0); the for(intI=0; i<nn;i++)if(s[i]=='a') A[I]=CD (1,0); -FFT (A,n,1); Wu for(intI=0; i<n;i++) a[i]=a[i]*A[i]; -FFT (a,n,-1); About $ for(intI=0; i<nn;i++)if(s[i]=='b') B[I]=CD (1,0); -FFT (B,n,1); - for(intI=0; i<n;i++) b[i]=b[i]*B[i]; -FFT (b,n,-1); A + for(intI=0; i<n;i++){ the intX=round (a[i].x+b[i].x); -X= (x+1)/2; $Ans= (ans+ (1<<X)-1)%MoD; the } the them=nn<<1|1; the for(intI=0; i<nn;i++) st[(i+1) <<1]=S[i]; -Mx=id=0; in for(intI=1; i<=m;i++){ the if(mx>i) P[i]=min (p[2*ID-I],MX-I);Elsep[i]=0; the while(i-p[i]-1>0&&i+p[i]+1<=m&&st[i-p[i]-1]==st[i+p[i]+1]) p[i]++; About if(I+P[I]>MX) mx=i+p[i],id=i; theAns= ((ans-(p[i]+1)/2)%mod+mod)%MoD; the } theprintf"%d\n", ans); + return 0; -}
View Code
"bzoj3160" million-path human tracking FFT