plz explain me how to approach this problem and the answer to this problem ..thnx in advance :)
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Name |
---|
Probability of hitting the target by SmallR is a/b so missing the target is (1-a/b). Similarly for Zanoes, probability of missing the target is (1-c/d). Probability of hitting the target by SmallR in first go is a/b and Zanoes will not get his turn. If SmallR misses the target then Zanoes will get his turn but we are interested in first hit by SmallR so all try's by Zanoes must be misses. Probability of hitting the target in second go by SmallR is ( Probability of missing the target by SmallR at first go ) * ( Probability of missing the target by Zanoes at first go ) * ( Probability of hitting the target by SmallR at second go ) which is (1-a/b) * (1-c/d) * (a/b). Similarly probability of hitting the target at third go is (1-a/b) * (1-c/d) * (1-a/b) * (1-c/d) * (a/b) i.e missing in first two trials by Zanoes and SmallR and a hit in third try by SmallR. Sum of the values to infinty gives the probability that SmallR will hit first no matter what. This is a geometric progression with common ratio (1-a/b) * (1-c/d) which is less than 1 and hence sum of infinte values is a finite number.
thank you for your explanation. May I ask you one thing:
In the problem description it says
The answer will be considered correct if the absolute or relative error doesn't exceed 10^(-6)
If we don't decide to solve the summation by hand in order to find the finite number, how can we know how many times we should loop in order to find the final result so that the error won't exceed 10^(-6)?
It is infinitely long series where each value is multiplied by (1-a/b)*(1-c/d) which is less than 1. So each value is less than the previous value and at some point it will be almost 0 but we don't know when. Apparently we have a formula for such a series, you can see here
[ sum = z * (1 / ( 1-r ) ); r=( ( 1-a/b ) * ( 1-c/d ) ) , z=a/b in this case ]So looping is not required, this formula is all we need . I hope i understood your question correctly.
You should use while loop:
while(delta>=EPS)
{
deltaX=(1-a/b)X(1-c/d);
ans=ans+delta
}