抛硬币正面期望_如果抛硬币,正面的数量多于反面的可能性

这篇博客讨论了一个寻找抛硬币后正面多于反面的概率问题,提出了使用动态编程来解决这个问题,以避免O(2^n)的时间复杂度,转而采用O(n*n)的解决方案。给出了C++实现和问题解释。
摘要由CSDN通过智能技术生成

抛硬币正面期望

Problem statement:

问题陈述:

Let N be a positive odd number. There are N coins, numbered 1, 2 , ... , N. For each i (1≤i≤N), when Coin i is tossed, it comes up heads with probability pi and tails with probability 1-pi.

N为正奇数。 有N个硬币,编号为1,2,...,N 。 对于每个i ( 1≤i≤N ),当投入硬币i时,它的出现概率为pi出现在正面 ,出现的概率为1-pi出现在尾部。

Find the probability of having more heads than tails if coins are tossed.

找到抛硬币后正面多于尾的概率。

Input:

输入:

The first line contains N, number of coins. The second line contains the probability of coming head in the coins.

第一行包含N个硬币数量。 第二行包含进入硬币的概率。

Output:

输出:

Output the probability of having more number of heads than tails if coins are tossed.

如果抛硬币,则输出正面比背面多的概率。

Example with explanation:

带有说明的示例:

    Input: 
    N=3
    [0.30, 0.60, 0.80]

    Output: 
    0.612

    The probability of having (Coin1,Coin2,Coin3) = (Head,Head,Head) 
    is 0.3×0.6×0.8 = 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值