Task about dice - combinatorics We have $27$ dice. We throw them all. What is the probability to have eight $6$s, nine $5$s and four $4s$ after throwing them? ($6$s means side of the die, which has$ 6$ dots; $5$s - same but $5$ dots; $4$s - by analogy)
Is the answer $\dfrac{3^6}{6^{27}}$  ???
 A: There are $6^{27}$ ways the dice can land (assuming you can distinguish them).
But, although $8$ dice need to have a six, any $8$ dice can be six.
Then, although $9$ of the remaining dice need to have a five, any $9$ of the remaining dice can be five.
So to count the combinations properly, choose the dice that get a certain number from what hasn't been accounted for.
First, pick the $8$ dice with six:  ${27 \choose 8}$.
Next, pick the $9$ dice with five:  ${19 \choose 9}$.
Next, pick the $4$ dice with four:  ${10 \choose 4}$.
Finally, choose one, two, or three for the remaining $6$ dice:  $3^6$.
(If you're wondering: "Will it be different if I choose the fours first?" the answer is no!)
So, the probability is:
$$P = \frac{{27 \choose 8}{19 \choose 9}{10 \choose 4}3^6}{6^{27}} \approx 3.07 \cdot 10^{-5}.$$
A: Here is a quick C++ program to empirically check this probability:
#include <iostream>
#include <vector>
#include <random>
#include <algorithm>
using namespace std;

int main () {
unsigned long long int draws, result=0, i;
int four, five, six, die, j;

random_device rd; mt19937 mt(rd());
uniform_real_distribution<double> rand(1, 7);

cout << "How many draws (in millions)? "; 
cin >> draws; draws *= 1000000;

for (i=0; i<draws; i++) {
six=0;five=0;four=0;

for (j = 0; j < 27; j++) {
    die = rand(mt);
    if (die == 6) six++;
    if (die == 5) five++;
    if (die == 4) four++;
    }
if (six == 8 && five == 9 && four == 4) result++;

  }
cout << "The probability is: " << result << "/" << draws;}

$$\approx 3 \cdot 10^{-5}.$$
