Problem C
DnD Dice

As a dungeon master, you are currently designing a campaign for your group of players. In the final battle of this campaign, the players need to roll a combination of multiple dice with varying numbers of sides, and the action of the enemy is determined by the sum of the numbers on the dice that were rolled. For balancing purposes, you want to sort these sums based on how likely they are to occur, so that you can assign appropriate events to each of them.
Given the number of dice of each type, and assuming the sides of each die are numbered from $1$ to the number of sides, find all possible sums of dice rolls and output them sorted by non-increasing probability.
Input
The input consists of:
-
One line with five integers $t$, $c$, $o$, $d$ and $i$, ($0 \le t, c, o, d, i \le 10$), giving the number of tetrahedra, cubes, octahedra, dodecahedra and icosahedra among the dice that are rolled. There is always at least one die, that is $t+c+o+d+i \ge 1$.
Output
Output all possible sums, ordered from most likely to least likely. If two sums occur with the same probability, then those sums may be printed in any relative order.
Sample Input 1 | Sample Output 1 |
---|---|
1 1 1 0 0 |
11 10 9 12 8 13 14 7 15 6 5 16 17 4 18 3 |
Sample Input 2 | Sample Output 2 |
---|---|
2 0 0 1 0 |
9 14 12 11 10 13 15 8 16 7 6 17 5 18 4 19 3 20 |
Sample Input 3 | Sample Output 3 |
---|---|
0 0 0 0 1 |
10 3 9 8 14 13 11 7 6 12 20 4 15 5 16 1 2 19 17 18 |