Given three integers N, M, X. The task is to find the probability of distributing M items among X bags such that first bag contains N items
Input : M = 7, X =3, N = 3
Output : 0.2
The Number of ways to keep 7 items in 3 bags is .
The Number of ways to keep 4 items in 2 bags is . As the first bag contains 3 items.
The probability is /
Input : M = 9, X = 3, N = 4
Output : 0.142857
In general, the Number of ways to place N items in K bags is .
- The Number of ways to keep M items in X bags is .
- The Number of ways to keep (M-N) items in (X-1) bags is . As the first bag contains N items.
- The probability is /.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Distributing M items in a circle of size N starting from K-th position
- Program to find the profit or loss when CP of N items is equal to SP of M items
- Ways to place 4 items in n^2 positions such that no row/column contains more than one
- Count ways to distribute m items among n people
- Maximum items that can be bought with the given type of coins
- Calculate the loss incurred in selling the given items at discounted price
- Count the number of ways to fill K boxes with N distinct items
- Find the distance covered to collect items at equal distances
- Count of ways to distribute N items among 3 people with one person receiving maximum
- Loss when two items are sold at same price and same percentage profit/loss
- Number of ways of distributing N identical objects in R distinct groups
- Maximum number of elements greater than X after equally distributing subset of array
- Number of ways of distributing N identical objects in R distinct groups with no groups empty
- Probability of rain on N+1th day
- Probability of a key K present in array
- Probability of getting more value in third dice throw
- Probability that two persons will meet
- Aptitude | Probability | Question 8
- Aptitude | Probability | Question 9
- Aptitude | Probability | Question 10
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.