UVa11427 Expect the Expected
2017-01-05 16:44
323 查看
数学期望 概率递推
每一天的概率都是独立且相同的。可以先推出每天打i盘赢j盘的概率f[i][j]
f[i][j]=f[i-1][j]*(1-p) + f[i-1][j-1]*p
输 赢
设此人打一天胜率不满足要求的概率为p
那么打一天的概率是1*p
打两天的概率是1*p*(p^2)
以此类推
----
题解待施工
学自http://www.cnblogs.com/neopenx/p/4282768.html
----
WA点:
1、a和b用double存,可能引起了精度误差。
2、输出没换行
/*by SilverN*/ #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<vector> using namespace std; const int mxn=110; int n; double f[mxn][mxn]; int main(){ int T;int i,j,a,b,cas=0; scanf("%d",&T); double p; while(T--){ memset(f,0,sizeof f); scanf("%d/%d%d",&a,&b,&n); p=(double)a/b; f[0][0]=1; f[0][1]=0; for(i=1;i<=n;i++){ f[i][0]=f[i-1][0]*(1-p); for(j=1;j*b<=i*a;j++){ f[i][j]=f[i-1][j]*(1-p)+f[i-1][j-1]*p; } } double res=0.0; for(i=0;i<=n;i++)res+=f [i];// double ans=1/res; printf("Case #%d: %d\n",++cas,(int)ans); } return 0; }
相关文章推荐
- uva 11427 Expect the Expected
- UVA 11427 Expect the Expected [概率]
- UVA 11427 - Expect the Expected
- UVA - 11427 Expect the Expected (DP+概率)
- UVa 11427 - Expect the Expected
- UVA 11427 - Expect the Expected (概率DP 期望)
- uva11427 Expect the Expected
- UVA 11427 Expect the Expected
- UVa 11427 Expect the Expected (数学期望 + 概率DP)
- UVA 11427 Expect the Expected
- uva 11427 - Expect the Expected(概率)
- UVA 11427 Expect the Expected
- Uva 11427 Expect the Expected
- UVA 11427 - Expect the Expected(概率递推期望)
- UVa 11427 (期望 DP) Expect the Expected
- UVA11427 Expect the Expected
- Uva 11427 Expect the Expected 概率dp 求数学期望
- UVA 11427 - Expect the Expected(概率递归预期)
- uva 11427 Expect the Expected 概率dp求期望
- UVA 11427 Expect the Expected (概率dp+推公式求期望 详解)