Constant optimization several times after finally card past, touching. success get rank last.
Orz the person CLJ:
Http://download.noi.cn/T/2014/CCF_CTSC2014.rar Decompression Password CCfCtsC2014
Orz god Ben and constant optimization techniques:
http://blog.miskcoo.com/2015/05/bzoj-3557
http://cjjlsdy.blog.163.com/blog/static/180370563201461133026/
Http://picks.logdown.com/posts/197310-solution-to-ctsc2014-random
http://vfleaking.blog.163.com/blog/static/1748076342014421105221134/
By the way, you know, the code output is different when you shoot.
Briefly describe the procedure:
Each number can be seen as a polynomial under GF (2), then mk=m0*x^k (mod x^m+x).
Need polynomial to take the mold, blog.miskcoo.com and picks.logdown.com have the explanation.
Then the first question fft+ fast power, the second question because X is good, then X is the MoD x^m+x the meaning of the group of generators, then x=x^2^m, the inverse of the polynomial A is a^ (2^m-2), to find an inverse.
The
is an optimization constant that can be multiplied without FFT (Orz VFK) by using a pressure-bit when n is smaller
#include <bits/stdc++.h> #define N (1<<21) using namespace std;struct vec{double X,y;vec (double x=0,double y= 0): X (x), Y (y) {}};vec operator+ (Vec A,vec b) {return VEC (A.X+B.X,A.Y+B.Y);} VEC operator-(VEC A,vec b) {return VEC (A.X-B.X,A.Y-B.Y);} VEC operator* (VEC A,vec b) {return VEC (a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);} void Fft (vec* q,int n,int m) {int i,j,k;for (i=j=0;i!=n;++i) {if (i<j) swap (q[i],q[j]); for (k=n>>1; (j^=k) <k;k >>=1);} for (i=2;i<=n;i<<=1) {Double A (2*m*acos ( -1)/i), VEC s (cos (a), sin (a)), for (j=0;j!=n;j+=i) {Vec t=1;for (k=j;k!= J+i/2;t=t*s,++k) {Vec U=q[k];vec v=t*q[k+i/2];q[k]=u+v;q[k+i/2]=u-v;}}} if (!~m) for (i=0;i!=n;++i) q[i].x/=n;} int* mem (int k) {return (int*) calloc (k,4);} struct Pol{int k,*u;pol (int v=0,int s=n): K (1), U (MEM (s)) {u[0]=v;} ~pol () {free (u);} int& operator[] (int i) {return u[i];} pol& operator= (int v) {K=1,u[0]=v;return *this;} pol& operator= (pol& v) {memcpy (u,v.u, (K=V.K)); return *this;} pol& operator+= (pol& v);p ol& operator*= (POl& v);}; int get (int k) {int i=1;for (; i<k;i<<=1); return i;} pol& pol::operator+= (pol& v) {for (int i=0;i!=k;++i) U[i]=u[i]+v[i]&1;return *this;} pol& pol::operator*= (pol& v) {if (!k| |! V.K) return *this=0;int i,j,n=k,m=v.k;k+=m-1;if (k<=1e4) {typedef unsignedlong long ds[200];static DS s,t;int q=k+63 >>6;fill (s,s+q,0), Fill (t,t+q,0), for (I=0;i!=m;++i) s[i>>6]|=0ull+v[i]<< (i&63), for (i=0;i!=n ; ++i) {if (U[i]) for (j=0;j!=q;++j) t[j]^=s[j];for (j=q-1;j;--j) s[j]=s[j]<<1|s[j-1]>>63&1;s[0]< <=1;} for (I=0;i!=k;++i) u[i]=t[i>>6]>> (i&63) &1;} Else{static Vec S[n],t[n];j=get (k); copy (u,u+n,s); copy (v.u,v.u+m,t); fill (s+n,s+j,0); fill (t+m,t+j,0); FFT (s,j,1); FFT (t,j,1), for (I=0;i!=j;++i) S[i]=s[i]*t[i];fft (s,j,-1), for (I=0;i!=k;++i) u[i]=int (s[i].x+.5) &1;} return *this;} void mov (pol& a,int k) {if (a.k<k) fill (a.u+a.k,a.u+k,0); a.k=k;} void Inv (pol& u,pol& v,int k) {if (k<=1) V=k;else{int M=K+1>>1;INV (u,v,m); MOV (v*=v,k); mov (v*=u,k);}} fix int (pol& a) {while (a.k&&!a[a.k-1])--a.k;return A.K;} void Rev (pol& u,pol& v,int k) {reverse_copy (u.u,u.u+u.k,v.u); V.k=u.k,mov (v,k);} void print (pol& a,const char* s= "") {printf ("%s", s), for (int i=0;i!=a.k;++i) printf ("%d", A[i]);p Utchar (10);} void Div (pol& a,pol& b,pol& d,pol& R) {if (fix (a) <fix (b)) d=0,r=a;else{static pol U,v;int k=a.k-b.k+1; Rev (A,d,k), rev (B,u,k), inv (u,v,k), MOV (d*=v,k); reverse (d.u,d.u+k); R=b,r*=d;mov (r,b.k-1), R+=a;}} void gcd (pol& a,pol& b,pol& x,pol& y) {if (!fix (b)) X=1,y=0;else{pol U (0,1<<11);p ol V (0,1<< One);d IV (A,B,U,V); gcd (b,v,y,x); U*=x,mov (Y,max (Y.K,U.K)), Y+=u;}} void Mul (pol& a,pol& b,pol& p) {if (!a.k| |! B.K) {A=0;return;} int I,j,k=a.k+b.k-1;if (K<P.K) {A*=b;return;} if (k<=1e4) {typedef unsignedlong long ds[200];static DS s,t,u;int Q=k+63>>6;fill (s,s+q,0); fill (t,t+q,0); for ( I=0;i!=b.k;++i) s[i>>6]|=0ull+b[i]<< (i&63); for (I=0;i!=p.k;++i) u[i>>6]|=0ull+p[i]<< (i&63); for (i=0;i!=a.k;++i) {if (A[i]) for (j=0;j!=q;++j) t[j]^=s[j];for (j=q-1;j;--j) s[j]=s[j]<<1 |s[j-1]>>63&1;s[0]<<=1;if (s[(p.k+63>>6) -1]>> (p.k-1&63) &1) for (J=0;J!=Q;++J) S[J]^=U[J];} A.k=p.k-1;for (i=0;i!=a.k;++i) a[i]=t[i>>6]>> (i&63) &1;} Else{static Pol U,v;u=a;div (U*=b,p,v,a);}} void Inv (pol& a,int m,pol& p) {static Pol U;u=a,a=1;while (--m) {mul (u,u,p); Mul (a,u,p);}} Template<class t>inline void Scan (t& x) {static int u;x=0;while ((U=getchar ()) <48);d Ox=x*10+u-48;while ((U =getchar ()) >32);} int main () {pol a,m0,u,v,x;int i,m,l,q;long long K;scan (m), for (i=0;i!=m;++i) scan (X[i]), for (i=0;i!=m;++i) scan (m0[i]); X.k=m0.k=m;x[x.k++]=1;if (Scan (q), q) {scan (L); for (i=0;i!=m;++i) scan (a[i]); A.K=M;INV (u=m0,m,x); Mul (a,u,x); for (i=0 ; i!=m-l;++i) Mul (a,a,x);} Else{a=u[1]=1,u.k=2;scan (k); for (; k;k>>=1) {if (k&1) Mul (a,u,x), if (k>>1) Mul (u,u,x);}} Mul (m0,a,x); for (I=0;i!=m;++i) Putchar (m0[i]+48);p Utchar (10);}
bzoj3557: [Ctsc2014] Random number