B. Archer
Time limit per test2 seconds
Memory limit per test256 megabytes
Inputstandard input
Outputstandard 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 shoshould 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 seconds-limit 6.
Sample test (s)
Input
1 2 1 2
Output
0.666666666667
Proportional sequence infinite summation formula a + ap ^ 2 +... 0 <p <1 --> S = a/(1-p)
[Cpp] # 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 --)
# Define Forp (x) for (int p = pre [x]; 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;
}
# 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 --)
# Define Forp (x) for (int p = pre [x]; 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;
}