The state transition equation for this question should be very good. If the equation cannot be pushed, you don't have to worry about it. You just need to do more to find the expected question.
If dp [I] is set, it indicates the number of throws that are expected to be throttled when I have been thrown in a different or the same status. Then dp [0] is the answer
The same situation:
Dp [0] = 1 + dp [1]
Dp [1] = 1 + (m-1) * dp [1] + dp [2])/m
Dp [I] = 1 + (m-1) * dp [1] + dp [I + 1])/m
...
Dp [n] = 0;
Let's take out the I and I + items.
Dp [I] = 1 + (m-1) * dp [1] + dp [I + 1])/m
Dp [I + 1] = 1 + (m-1) * dp [1] + dp [I + 2])/m
Offset: m * (dp [I]-dp [I + 1]) = dp [I + 1]-dp [I + 2];
If d [I] = dp [I]-dp [I + 1] is set, d [] is an proportional sequence with a common ratio of m, and d [0] = 1;
So d [I] = m ^ I, and then dp [0]-dp [I + 1] = m ^ 0 + m ^ 1 + ..... + m ^ I;
If I + 1 = n, dp [0] = m ^ 0 + m ^ 1 +... + m ^ (n-1 );
Different situations:
Dp [0] = 1 + dp [1]
Dp [1] = 1 + (dp [1] + m-1) dp [2])/m
Dp [2] = 1 + (dp [1] + dp [2] + (m-2) dp [3])/m
Dp [I] = 1 + (dp [1] + dp [2] +... dp [I] + (m-I) * dp [I + 1])/m
...
Dp [n] = 0;
In the same case, select dp [I] and dp [I + 1] to subtract
Dp [I]-dp [I + 1] = (m-i-1)/m * (dp [I + 1]-dp [I + 2]);
D [I] = dp [I]-dp [I + 1]. then d [I] = (m-i-1)/m * d [I + 1], and d [0] = 1;
This formula looks similar to the same, but it cannot be simplified.
However, we can find every d [I] based on this recursive relationship.
Then, when the column items are eliminated, we can find that dp [0] = d [0] + d [1] + d [2] + ...... + d [n-1];
Using these two formulas, the code can be AC very short, so the code is not given