zoukankan      html  css  js  c++  java
  • P6046

    题意

    链接

    (n) 个物品排成一列,第 (i) 个物品强度为 (a_i)。每一秒会随机选择两个相邻的物品相撞,强度较小的那个会破碎,被移除队列(即原本不相邻的物品可能会现在相邻)。求每个物品存活时间的期望。

    $O(n^2) $ 解法

    (P(i=x)) 为某物品存活时间等于 (i) 的概率,则显然 (E=sumlimits_{i=1}^{n-1}iP(i=x))

    展开来就是

    [egin{align} E&=P(1=x)+2P(2=x)+3P(3=x)+...\ &=(P(1=x)+P(2=x)+P(3=x)+...)+(P(2=x)+P(3=x)+...)+(P(3=x)+...)+...\ &=P(1le x)+P(2le x)+P(3le x)+...\ &=sum_{i=1}^{n-1}P(ile x) end{align} ]

    重申 (large E=sum_limits{i=1}^{n-1}P(ile x))

    于是设 (pre) 为在物品 (x) 左边第一个强度比它大的物品, (nxt) 为在物品 (x) 右边第一个强度比它大的物品。则如果 (presim x) 一段物品或 (xsim nxt)​ 一段物品全部被打碎,则这个物品就碎了。

    (P(A))(presim x) 全部破碎的概率, (P(B))(xsim nxt) 全部破碎的概率。则 (P(Aand B))(presim nxt) 全部破碎的概率。

    (P(ige x)=P(A)+P(B)-P(Aand B))

    (d_1=x-pre,d_2=nxt-x)​,有 (P(ile x)=1-P(A)-P(B)+P(Aand B)=1-frac{left(egin{array}{c} n-1-d_{1} \ i-d_{1} end{array} ight)}{left(egin{array}{c} n-1 \ i end{array} ight)}-frac{left(egin{array}{c} n-1-d_{2} \ i-d_{2} end{array} ight)}{left(egin{array}{c} n-1 \ i end{array} ight)}+frac{left(egin{array}{c} n-1-d_{1}-d_{2} \ i-d_{1}-d_{2} end{array} ight)}{left(egin{array}{c} n-1 \ i end{array} ight)})

  • 相关阅读:
    js点击左右滚动+默认自动滚动类
    左右箭头+按钮+左右滑动幻灯
    超酷视频播放器详细地址
    经典123幻灯切换
    js左右滚动幻灯
    js数组操作
    js删除数据的几种方法
    【转】MySQL的各种timeout
    Mysql 分段统计
    【转】linux yum命令详解
  • 原文地址:https://www.cnblogs.com/BlankAo/p/15143924.html
Copyright © 2011-2022 走看看