uva 11427 Expect the Expected

Posted 日拱一卒 功不唐捐

tags:

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

https://vjudge.net/problem/UVA-11427

 

大佬题解:

http://www.cnblogs.com/xiong-/archive/2013/08/14/3258476.html

 

#include<cstring>
#include<cstdio>
using namespace std;
double    Q,dp[101][101],p;
int main()
{
    int t,a,b,n;
    scanf("%d",&t);
    for(int tt=1;tt<=t;tt++)
    {
        scanf("%d/%d%d",&a,&b,&n);
        memset(dp,0.0,sizeof(dp));
        dp[0][0]=1.0; p=1.0*a/b;
        for(int i=1;i<=n;i++)
         for(int j=0;j*b<=i*a;j++)
           {
               dp[i][j]=dp[i-1][j]*(1-p);
               if(j) dp[i][j]+=dp[i-1][j-1]*p;
           }
        Q=0.0;
        for(int i=0;i*b<=n*a;i++) Q+=dp[n][i];
        printf("Case #%d: %d\\n",tt,(int)(1/Q));
    }
}

 

以上是关于uva 11427 Expect the Expected的主要内容,如果未能解决你的问题,请参考以下文章

UVA 11427 Expect the Expected

UVA.11427.Expect the Expected(期望)

UVA - 11427 Expect the Expected

UVA11427 Expect the Expected

UVA11427 Expect the Expected

Expect the Expected UVA - 11427(概率dp)