Thinking: First of all, consider the situation of t=1, T equals 1, then all the positions of the same color, we do not consider the probability of the problem, then, k+d*x in modulo d are equal, we consider preprocessing an array s[i][j], representing D as I, starting position is J arithmetic progression and, this can prove that, When the modulus is less than or equal to sqrt (n) can be solved perfectly, the time complexity of n^1.5, for D is greater than sqrt (n), only need to be violent enumeration.

Again consider the situation of t>=2, we choose the color must be the least number of colors, the minimum color of the expectation is absolute minimum, then we divide the left side of K and K to calculate, we call k+d*x position here, called the key position, assuming P[i] For I to k all key positions in this section are all the same color probability, then the transfer is p[i+k]=p[i]* (x)/(N-1-x), X is the minimum number of colors. We can see that,x< (n-1)/2,p[i] is attenuated by the exponential, so we only need to enumerate a small segment, when P[i]<eps, then it has little effect on the answer.

1#include <algorithm>2#include <cstdio>3#include <cmath>4#include <cstring>5#include <iostream>6 intblock,n,m;7 ints[2005][2005],a[200005];8 Const Doubleeps=1e- -;9 intRead () {Ten intt=0, f=1;CharCh=GetChar (); One while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} A while('0'<=ch&&ch<='9') {t=t*Ten+ch-'0'; ch=GetChar ();} - returnt*F; - } the voidinit () { -N=read (); m=read (); - for(intI=1; i<=n;i++) a[i]=read (); -Block=ceil (sqrt (n)) +0.1; + for(intI=1; i<=block;i++) - for(intj=1; j<=i;j++) + for(intk=j;k<=n;k+=i) As[i][j]+=A[k]; at } - voidModifyintXinty) { - intt=y-A[x]; - for(intI=1; i<=block;i++) -s[i][(x1)%i+1]+=T; -a[x]=y; in } - DoubleDealintKintd) { to if(D<=block)returns[d][(K-1)%d+1]; + Doubleres=0; - for(intI= (K-1)%d+1; i<=n;i+=d) theres+= (Double) a[i]; * returnRes; $ }Panax Notoginseng voidsolve () { - while(m--){ the intopt=read (); + if(opt==1){ A intX=read (), y=read (); theModify (x, y);Continue; + } - intnum=0x7fffffff, t,k,d; $T=read (); K=read ();d =read (); for(intI=1; i<=t;i++) {intL=read (); num=std::min (num,l);} $ if(t==1) {printf ("%.4f\n", Deal (K,D));Continue;} - DoubleAns= (Double) a[k],p=1; - intn=num; the for(inti=k+d,num=n-1;i<=n&&num>0; I+=d,num--, num--){ -p=p*num/num;ans+=p*A[i];Wuyi if(p<eps&&n>= +) Break; the } -num=n;p=1; Wu for(inti=k-d,num=n-1; i>=1&&num>0; I-=d,num--, num--){ -p=p*num/num;ans+=p*A[i]; About if(p<eps&&n>= +) Break; $ } -printf"%.4f\n", ans); - } - } A intMain () { + init (); the solve (); -}

Bzoj NOI 10 Continuous measurement of the first Test T1