-
I - Bag of mice
- CodeForces - 148D
-
#include<bits/stdc++.h> using namespace std; #define maxn 1111 double dp[2*maxn][maxn]; int w,b; int main() { scanf("%d%d",&w,&b); memset(dp,0.0,sizeof(dp)); for(int i=1; i<=w; i++) { dp[i][0]=1.0; for(int j=1; j<=b; j++) { double x=i; double y=j; //直接获胜 dp[i][j]+=x/(x+y); //两个全抓的黑的之后获胜分两种情况跑出黑的跑出白的 if(j>=3) dp[i][j]+=y/(x+y)*(y-1.0)/(x+y-1.0)*(y-2.0)/(x+y-2.0)*dp[i][j-3]; if(j>=2) dp[i][j]+=y/(x+y)*(y-1.0)/(x+y-1.0)*(x)/(x+y-2.0)*dp[i-1][j-2]; } } printf("%.9lf\n",dp[w][b]); return 0; }
I - Bag of mice CodeForces -概率DP
最新推荐文章于 2023-01-29 00:48:34 发布