Archer
Time Limit: 2000ms
Memory Limit: 262144KB
This problem will be judged on CodeForces. Original ID: 312B
64-bit integer IO format: %I64d Java class name: (Any)
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 .
Output
Print a single real number, the probability that SmallR will win the match.
The answer will be considered correct if the absolute or relative error doesn‘t exceed 10 - 6.
Sample Input
Input
1 2 1 2
Output
0.666666666667
Source
Codeforces Round #185 (Div. 2)
解题:等比数列求和的极限
1 #include <bits/stdc++.h> 2 using namespace std; 3 int a,b,c,d; 4 int main(){ 5 while(~scanf("%d%d%d%d",&a,&b,&c,&d)) 6 printf("%.8f\n",(double)a*d/(a*d+b*c-c*a)); 7 return 0; 8 }