题意:进行翻硬币实验,若k次向上则结束,进行第n次实验需花费2*n-1的费用,询问期望结束次数及期望结束费用
设F[i]为第i次结束时的概率
F[i]= c(i-1,k-1)*p^k*(1-p)^(i-k)
sigma(f[i])==1
p^k*sigma(c(i-1,k-1)*(1-p)^(i-k))=1
sigma(c(i-1,k-1)*(1-p)^(i-k))=1/(p^k)
ans1=sigma(i*f[i])
=p^k*sigma(i*c(i-1,k-1)*(1-p)^(i-k)) //将i放入组合数
=k*p^k*sigma(c(i,k)*(1-p)^(i-k))
=k*p^k*p^(k+1)
=k/p
ans2=sigma(i*i*f[i])
=p^k*sigma(i*i*c(i-1,k-1)*(1-p)^(i-k))
=k*p^k*sigma(i*c(i,k)*(1-p)^(i-k))
=k*p^k*sigma((i+1)*c(i,k)*(1-p)^(i-k))-p^k*sigma(c(i,k)*(1-p)^(1-k))
=k*(k+1)*p^k*sigma(c(i+1,k+1)*(1-p)^(i-k))-ans1 //将i+1放进去
=k*(k+1)*p^k/(p^(k+2))-ans1
=k*(k+1)/p^2-ans1
=[(k+1)/p]*ans1-ans1
发现这种做法并没有通用性
打算开始着手学习概率DP的入门
等入门后再补上DP的解法
期望一般从后面往前面推