#P16770. [GKS 2020 #F] Yeetzhee
[GKS 2020 #F] Yeetzhee
Problem Description
Pommel is very bored at home so she has invented a new game involving dice. Each die has the numbers from to written on it. Whenever she throws a die, it has an equal probability of landing on each of the possible values.
Pommel places all the dice in a row. She goes through the dice one at a time from left to right. For each die she rolls, Pommel can either keep the value she rolled and move on to the next die or she can re-roll the die. Pommel can re-roll a die as much as she wants before moving on to the next die.
Once Pommel has gone through all the dice, the game is finished. To determine if she has won, she puts the dice into groups. All dice with the same value are put into the same group. So if she finishes the game with distinct values, then there will be groups. These groups of dice are then sorted by number of dice in non-decreasing order.
For example:
- If the final dice results are , the dice would be put into groups and ordered as follows: and .
- If the final dice results are , the dice would be put into groups and ordered as follows: , , and (or equivalently, , and ).
Pommel wins if she finishes the game with exactly groups, and the -th group contains exactly dice, for all .
What is the expected value of the total number of dice rolls it will take Pommel to win the game, assuming she plays optimally to minimize this expected value?
It is guaranteed that for any valid input, it is possible for Pommel to win the game.
Input Format
The first line of the input gives the number of test cases, . test cases follow. The first line of each test case contains the integers , , and . Then, lines follow describing the groups she must finish with. The -th line contains .
Output Format
For each test case, output one line containing Case #: `, where is the test case number (starting from ) and is the expected number of times it will take to roll all the dice for Pommel to win the game.
will be considered correct if it is within an absolute or relative error of of the correct answer.
2
3 6 2
1
2
5 2 1
5
Case #1: 4.7
Case #2: 9.0
Hint
In Sample case #, Pommel has dice, each with a number from to written on them. To win, she must finish the game with groups. One group must have die (), while the other group must have dice (). One optimal strategy for Pommel is as follows:
- Pommel throws the first die time.
- Pommel throws the second die time.
- If the first and second dice are the same, Pommel keeps throwing the third die until it ends in a different value from the first two. It takes dice rolls on average.
- If the first and second dice are different, Pommel keeps throwing the third die until it matches the first or the second die. It takes dice rolls on average.
This strategy takes Pommel () dice rolls on average.
In Sample case #, Pommel has dice, each with a number from to written on them. To win, she must finish the game with group, with all dice in it (). For die , Pommel rolls it time. Then, for each remaining die, she keeps rolling until it has the same value as die . It takes dice rolls on average.
This strategy takes Pommel () dice rolls on average.
Limits
.
.
, for all .
.
, for all .
Test Set
.
.
Test Set
.
.