AtCoder Beginner Contest 270 EX(期望)

Posted 吃花椒的妙酱

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AtCoder Beginner Contest 270 EX(期望)相关的知识,希望对你有一定的参考价值。

题意:n个数ai,和n个计数器ci(初始都为0),每次等概率选一个计数器置0,其他计数器+1,求所有计数器变成ai的期望次数。(a1=0,n<=2e5,ai<=1e18,ai数组不减)
Solution:
\\quad 设置一个状态 s t a t e = m a x ( a i − c i ) state = max(a_i-c_i) state=max(aici),当state = 0时就结束了,初始state = a n a_n an
\\quad E k E_k Ek表示state=k时到达state=0的期望次数。每次操作将某个ai-ci变成ai,state变成 m a x ( a i , a j − c j − 1 ) , j ≠ i max(ai,aj-cj-1),j\\neq i max(ai,ajcj1),j=i
state=k时,如果选择 a i < k ai<k ai<k去置0,则state不变。
如果选择ai>=k去置0,则state = k-> state = a i a_i ai
a r < k < = a r + 1 a_r<k<=a_r+1 ar<k<=ar+1(即最大的ai,小于k),有 E k = 1 + 1 n ( r E k − 1 + ∑ j = r + 1 n E a j ) = > E k − 1 = 1 r ( n ( E k − 1 ) − ∑ j = r + 1 n E a j ) E_k =1+\\frac1n(rE_k-1+\\sum_j=r+1^n E_a_j)=>E_k-1 = \\frac1r(n(E_k-1)-\\sum_j=r+1^n E_a_j) Ek=1+n1(rEk1+j=r+1nEaj)=>Ek1=r1(n(Ek1)j=r+1nEaj)
然后我们已知 E 0 = 0 , 要求 E a n E_0=0,要求E_a_n E0=0,要求Ean,而这个递推式的顺序是反的。改写一下
T k = E a n − E k T_k = E_a_n-E_k Tk=EanEk,已知 T a n = 0 要求 T_a_n=0要求 Tan=0要求 T 0 T_0 T0

E a n − E k − 1 = E a n − 1 r ( n ( E k − 1 ) − ∑ j = r + 1 n E a j ) = T k − 1 = 1 r ( n ( T k + 1 ) − ∑ j = r + 1 n T a j ) , a r < k < = a r + 1 E_a_n-E_k-1 =E_a_n- \\frac1r(n(E_k-1)-\\sum_j=r+1^n E_a_j)=\\\\ T_k-1=\\frac1r(n(T_k+1)-\\sum_j=r+1^n T_a_j),a_r<k<=a_r+1 EanEk1=Eanr1(n(Ek1)j=r+1nEaj)=Tk1=r1(n(Tk+1)j=r+1nTaj),ar<k<=ar+1
现在就可以倒着推了。
式子后面的 ∑ j = r + 1 n T a j \\sum_j=r+1^n T_a_j j=r+1nTaj,对于一些k是不会变的,也就是说只会变n-1次,所以可以看作常数,然后枚举这段变化。

s = ∑ j = r + 1 n T a j , a r < k < = a r + 1 s =\\sum_j=r+1^n T_a_j,a_r<k<=a_r+1 s=j=r+1nTaj,ar<k<=ar+1

以上是关于AtCoder Beginner Contest 270 EX(期望)的主要内容,如果未能解决你的问题,请参考以下文章

AtCoder Beginner Contest 234

AtCoder Beginner Contest 115 题解

AtCoder Beginner Contest 154 题解

AtCoder Beginner Contest 103

AtCoder Beginner Contest 228

AtCoder Beginner Contest 242