Given four integers a, b, c and d. Player A & B try to score a penalty. Probability of A shooting the target is a / b while probability of B shooting the target is c / d. The player who scores the penalty first wins. The task is to find the probability of A winning the match.
Input: a = 1, b = 3, c = 1, d = 3
Input: a = 1, b = 2, c = 10, d = 11
Approach: If we consider variables K = a / b as the probability of A shooting the target and R = (1 – (a / b)) * (1 – (c / d)) as the probability that A as well as B both missing the target.
Therefore, the solution forms a Geometric progression K * R0 + K * R1 + K * R2 + ….. whose sum is (K / 1 – R). After putting the values of K and R we get the formula as K * (1 / (1 – (1 – r) * (1 – k))).
Below is the implementation of the above approach:
- Find probability that a player wins when probabilities of hitting the target are given
- Write a function that generates one of 3 numbers according to given probabilities
- Find the minimum possible health of the winning player
- Find the ratio of number of elements in two Arrays from their individual and combined average
- Count of strings whose prefix match with the given string to a given length k
- Minimum moves to reach target on a infinite line | Set 2
- Count the number of ways to construct the target string
- Find amount to be added to achieve target ratio in a given mixture
- Find minimum moves to reach target on an infinite line
- Probability of rain on N+1th day
- Aptitude | Probability | Question 4
- Aptitude | Probability | Question 5
- Aptitude | Probability | Question 6
- Aptitude | Probability | Question 7
- Probability that two persons will meet
- Aptitude | Probability | Question 1
- Probability of a key K present in array
- Aptitude | Probability | Question 2
- Aptitude | Probability | Question 3
- Aptitude | Probability | Question 8
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.