UVA 11427 Expect the Expected (期望)
2013-12-01 19:13
330 查看
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2422
题意:每天玩纸牌游戏,若胜的概率严格大于p时结束,第二天接着玩。每天最多玩n盘,n盘之后概率还是没有严格大于p,则结束而且以后再也不玩了。问玩多少天之后就不玩了。
思路:
int a,b,n;
double f
;
int main()
{
int num=0;
rush()
{
scanf("%d/%d %d",&a,&b,&n);
double p=1.0*a/b;
clr(f,0);
f[0][0]=1;
int i,j;
FOR1(i,n) for(j=0;j*b<=a*i;j++)
{
f[i][j]=f[i-1][j]*(1-p);
if(j) f[i][j]+=f[i-1][j-1]*p;
}
double ans=0;
for(i=0;i*b<=a*n;i++) ans+=f
[i];
printf("Case #%d: %d\n",++num,(int)(1/ans));
}
}
题意:每天玩纸牌游戏,若胜的概率严格大于p时结束,第二天接着玩。每天最多玩n盘,n盘之后概率还是没有严格大于p,则结束而且以后再也不玩了。问玩多少天之后就不玩了。
思路:
int a,b,n;
double f
;
int main()
{
int num=0;
rush()
{
scanf("%d/%d %d",&a,&b,&n);
double p=1.0*a/b;
clr(f,0);
f[0][0]=1;
int i,j;
FOR1(i,n) for(j=0;j*b<=a*i;j++)
{
f[i][j]=f[i-1][j]*(1-p);
if(j) f[i][j]+=f[i-1][j-1]*p;
}
double ans=0;
for(i=0;i*b<=a*n;i++) ans+=f
[i];
printf("Case #%d: %d\n",++num,(int)(1/ans));
}
}
相关文章推荐
- UVa 11427 (期望 DP) Expect the Expected
- UVA 11427 Expect the Expected【期望】
- UVA 11427 Expect the Expected (概率dp+推公式求期望 详解)
- UVA 11427 - Expect the Expected (概率DP 期望)
- UVa 11427 Expect the Expected (数学期望 + 概率DP)
- Uva 11427 Expect the Expected 概率dp 求数学期望
- uva 11427 Expect the Expected 概率dp求期望
- uva11427 Expect the Expected
- UVA - 11427 Expect the Expected (DP+概率)
- UVa11427 Expect the Expected
- UVA 11427 Expect the Expected(DP+概率)
- UVA 11427 Expect the Expected [概率]
- UVA 11427 - Expect the Expected
- 11427 - Expect the Expected(概率期望)
- uva 11427 - Expect the Expected(概率)
- UVa 11427 - Expect the Expected
- UVA 11427 Expect the Expected
- UVA 11427 - Expect the Expected(概率递归预期)
- 概率DP,记忆化搜索(Expect the Expected,uva 11427)
- UVa 11427 Expect the Expected