0
点赞
收藏
分享

微信扫一扫

CF 312B(Archer-等比数列极限求和)



B. Archer



time limit per test



memory limit per test



input



output


SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is 

 for SmallR while 

 for Zanoes. The one who shoots in the target first should be the winner.

Output the probability that SmallR will win the match.


Input

A single line contains four integers 

CF 312B(Archer-等比数列极限求和)_i++

.

Output


Print a single real number, the probability that SmallR will win the match.

10 - 6.


Sample test(s)


input


1 2 1 2


output


0.666666666667




等比数列无限求和公式 a+ap+ap^2+...    0<p<1   -->     S=a/(1-p)



#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<cctype>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define RepD(i,n) for(int i=n;i>=0;i--)
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
double a,b,c,d;
cin>>a>>b>>c>>d;
printf("%.12lf\n",a/b/(1-(1-a/b)*(1-c/d)));

return 0;
}



举报

相关推荐

0 条评论