Reference no: EM132399184
It is well known that a dice is a cube with number 1 to 6 written on each face, but in fact there exist irregular dices with different number of faces (e.g. 4, 5, 8...etc). A coin can also be considered as a dice of 2 faces as well.
When an unbiased dice is thrown, the probability of having different face value should be equal. For instance, a typical cubic dice should give a probability of 1/6 for the face values 1,2,3,4,5 and 6.
If two cubic dices were thrown, the total of the face values on the two dices is in range [2..12]. However, the probability of each "total value" is not equal. For example, the total of 4 is having a probability of 3/36 (for combinations 1+3, 2+2 and 3+3) while the probability of a total of 2 is only 1/36 (when both dices give 1).
Help me to write a program to find out the probability of each "total value" when several unbiased irregular dices (possibly with different number of faces) are thrown at the same time.Only #include<iostream> and <iomanip> are allowed.
The program should first read in the number of dices, N (range: [1..12] inclusive).
Then the program will read in N numbers, each representing the number of faces of a dice (range: [1..12] inclusive. Of course it's physically impossible to have a one-face dice, but you can imagine that it's a dice with 1 written on all faces)
Finally the program should output the probability of each "total value" in fractional form. (you may assume that the denominator of the fraction is always small enough for a 32bit integer)