$5$ fair dice and put away all dice showing a unique value, but re-roll any dice set that have the same value (one set at a time), and continue doing this until you have put away all the dice, then the expected sum of all the dice is $\frac{p}{q}$ where $p$ and $q$ are relatively prime integers. Find $p + q$ .

If you start by rollingFor example, one sequence could be that you roll three $3$ 's and two $2$ 's for a partial sum of $3 + 3 + 3 + 2 + 2 = 13$ , then you would re-roll the three $3$ 's to get two $6$ 's and one $2$ for a partial sum of $13 + 6 + 6 + 2 = 27$ , then you would put away the single $2$ (since it is unique to that roll) and re-roll the two $6$ 's to get one $1$ and one $2$ for a partial sum of $27 + 1 + 2 = 30$ , then you would put away both those dice (since they are different) and now re-roll the two $2$ 's (from the first roll) and get one $3$ and one $4$ for a final sum of $30 + 3 + 4 = 37$ .

The answer is 47431.

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

Expectation is additive, so we can concentrate on one die. Every time we roll a die, the expected outcome is $3.5,$ so the expected sum equals $3.5 \cdot 5 \cdot N_5,$ where $N_5$ is the expected number of times we will roll a given die when it is one of $5.$

We get a system of equations as follows: $\begin{aligned} N_2 &= \frac16 N_2 + 1 \\ N_3 &= \frac1{36} N_3 + \frac{10}{36} N_2 + 1 \\ N_4 &= \frac1{216} N_4 + \frac{15}{216} N_3 + \frac{75}{216} N_2 + 1 \\ N_5 &= \frac1{1296} N_5 + \frac{20}{1296} N_4 + \frac{150}{1296} N_3 + \frac{500}{1296} N_2 + 1 \end{aligned}$ Each of the fractions in the above system of equations is the probability that the die we roll will be part of a group of a given size with the same result. For instance, the coefficient of $N_3$ in the last equation is the probability that the die we roll will be a part of a group of $3$ with the same result, which is the probability that exactly $2$ of the other $4$ dice match our die, which is $\binom{4}{2} \left( \frac16 \right)^2 \left( \frac56 \right)^2 = \frac{150}{1296}.$

The solution of this system is $\begin{aligned} N_2 &= \frac65 \\ N_3 &= \frac{48}{35} \\ N_4 &= \frac{2286}{1505} \\ N_5 &= \frac{18336}{11137} \end{aligned}$ and the expected sum is $\frac{18336}{11137} \cdot \frac{35}2 = \frac{45840}{1591},$ so the answer is $\fbox{47431}.$