plz explain me how to approach this problem and the answer to this problem ..thnx in advance :)

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3520 |

2 | tourist | 3430 |

3 | apiadu | 3351 |

4 | mnbvmar | 3332 |

5 | Benq | 3290 |

6 | LHiC | 3276 |

7 | TLE | 3270 |

8 | Radewoosh | 3251 |

9 | ecnerwala | 3241 |

10 | Um_nik | 3240 |

# | User | Contrib. |
---|---|---|

1 | antontrygubO_o | 190 |

2 | Errichto | 188 |

3 | tourist | 179 |

4 | Radewoosh | 172 |

5 | pikmike | 166 |

6 | vovuh | 165 |

7 | ko_osaga | 162 |

8 | Um_nik | 161 |

9 | rng_58 | 155 |

10 | majk | 154 |

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/19/2020 15:12:18 (e2).

Desktop version, switch to mobile version.

Supported by

User lists

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

}

Wow! Thank you for the crystal clear explanation :))