1 #include <iostream>
2 using namespace std;
3 double g[105]={0,1};
4 int n,m;
5 double p,q;
6 double solve(){
7 if(n==0) return 0;
8 if(m==0) return 1;
9 if(p==0&&q==1) return 0;
10 if(p==1&&q==0) return 1;
11 int i;
12 double a=(p-1)*q/(p*(1-q)),b=(p+q-2*p*q)/(p*(1-q));
13 for(i=2;i<=n+m;i++)
14 g[i]=a*g[i-2]+b*g[i-1];
15 return g[n]/g[n+m];
16 }
17 int main(){
18 //freopen("in.txt","r",stdin);
19 while (~scanf("%d %d %lf %lf",&n,&m,&p,&q)){
20 printf("%.2lf\n",solve());
21 }
22 return 0;
23 }
posted on 2012-07-13 10:14
Leo.W 阅读(352)
评论(0) 编辑 收藏 引用