A multinomial problem has been solved programmatically, could someone please give a hint about how to solved it mathematically? This post gives an example of Multinomial Distribution.

Two chess players have the probability Player A would win is 0.40, Player B would win is 0.35, game would end in a draw is 0.25.
The multinomial distribution can be used to answer questions such as: “If these two chess players played 12 games, what is the probability that Player A would win 7 games, Player B would win 2 games, the remaining 3 games would be drawn?”

That post has solved the problem programmatically in R.
dmultinom(x=c(7,2,3), prob = c(0.4,0.35,0.25))
## [1] 0.02483712

Could someone please give a hint about how to solved the problem mathematically?
someone gave a formula for this
$$n = \frac{12!}{7! \times 2! \times 3!}$$
the denominator represents all the possible unique ways to get the combination of (Player A wins 7 games, Player B wins 2 games, 3 drawn)
what does the $12!$ part represent?
the corresponding R code is
(factorial(x = 12) / (factorial(x = 7) * factorial(x = 2) * factorial(x = 3))) * (0.4 ^ 7) * (0.35 ^ 2) * (0.25 ^ 3)

and got
#> [1] 0.02483712

the result is equal to the first one, but why? where does this code from?
 A: What we need to solve this question are two things
1) How likely is one pattern where player A wins 7 games, Player B two games, and 3 draws. For example AAAAAAABBDDD This is $p = 0.4^7*0.35^2*0.25^3 = 3.136^{-6}$ 
2) The number of patterns with 7 wins for A two wins for B and 3 draws.
This is a permutation of multisets (see Wikipedia)
$ n!/k_1!k_2!...k_m!$ $n$ = number of elements and n! is the number of possible sequences of n different objects  $k_1 ... k_m$= Number of similar elements of each group, By dividing we correct for the n! for the fact that we do not have n different objects but instead some groups
For your chess problem n = 12 as it is the number of games, k1 = 7 (wins for A), k2= 2 (wins for B) and k3= 3 (draws)
so you get your formula
Now you multiply the number of similar patterns with the probabily of one of those patterns (they all have the same probabilty) and you get your result of 0.02483712.
I hope this is helpful. I did not know whether you wanted more details than that.
