Expected = Total number of decrements in all cases
The number of decrements between the end of I and the i-1 will be recursive.
Part of it is after the i-1, and part of it is a new generation after the first one has been put out.
Note minus the extra parts.
2 I can play a table, and then open a sum preprocessing 2 of the I-side prefix and, can be recursive.
#include <cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespacestd;Const intmaxn=100000+Ten;Long Longmod=1e9+7;Long LongW[MAXN],ANS,Q[MAXN],SUM[MAXN];intn,x;Long LongMLong LongALong Longb) { while(a<0) {a=a+b;} A=a%b;returnA;}voidinit () {q[0]=q[1]=1; for(intI=2; i<=100000; i++) Q[i]=m (2*q[i-1],mod); sum[0]=1; for(intI=1; i<=100000; i++) Sum[i]=m (sum[i-1]+q[i],mod);}intMain () {init ();intT scanf"%d",&u); while(t--) {scanf ("%d", &n); Memset (W,0,sizeofW); ans=0; for(intI=1; i<=n;i++) {scanf ("%d",&x); if(i!=1) Ans=m (ans+sum[i-2]-w[x],mod); W[X]=m (w[x]+q[i-1],MOD), ans=ans*2; } printf ("%lld\n", M (Ans,mod)); } return 0;}
ZOJ 3929 Deque and Balls