当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5070:Twelve Months

Special Judge 特殊评判
题目描述
It is 23:55 on December 31. Squark is playing Twelve Months.

Twelve Months is a poker divination game well-known in some regions of China. It is believed to be able to predict one’s luck in each month in the coming year on New Year’s Eve. 48 cards, a standard 52-card deck excluding 4 Kings, are used in the game. First the 48 cards are shuffled randomly and evenly distributed into 12 stacks facedown. Each stack stands for a month, i.e. the first stack stands for January, the second stack stands for February, etc. Then, starting from the first stack, the player repeats the following process until all the cards are opened in the current stack.

1.Open the topmost unopened card from the current stack;

2.Move to the stack pointed by the number of the card just opened (Ace is the first, Jack is the eleventh and Queen is the twelfth), i.e. the new stack becomes the current stack.

According to the prediction, the player will be lucky in a month if the stack standing for the month is cleared, i.e. all the cards in that stack are opened. Of course, each player can only do the divination once in one year. Repeating the divination will have no effect. Maybe you have realized that the first stack will always be cleared, so the player will always be satisfied because he/she will be at least lucky in the coming month.

Squark has distributed his cards and opened a few of them according to the rule. Suddenly, an urgent phone call comes and interrupts his game. It is from Sevenkplus asking him about some difficult algebraic geometry problems. These problems are so difficult that Squark spends a lot of time but solves none of them. When Squark comes back to his cards, they has been gathered and put into one stack. Squark cannot restore the game to the situation when he left. Furthermore, Squark cannot play the game again as the clock has passed 12 o’clock and it is January 1 now. Fortunately, Squark can still remember the cards he opened and the exact open sequence. So he wants to know the probability of each possible result if he could have continued the game.

As January is always a lucky month, there are 211 possible results regarding the luckiness in the other months. We define a comparison method for these results to sort them, which compares the luckiness in December first, and then in November, and so on. To be unlucky is considered to be smaller than to be lucky.

To simplify the work to test your program, Squark considers the number of months in each year to be n instead of 12. In this way, the number of possible results is 2n - 1 instead of 211.
输入解释
The first line contains an integer T (T ≤ 40) denoting the number of the test cases.

For each test case, the first line contains 2 integers n(2 ≤ n ≤ 12) and m(0 ≤ m ≤ 4n), where n is the number of months in each year and m is the number of cards Squark opened. The second line contains m integers, standing for the cards opened by Squark (1 for Ace, 11 for Jack and 12 for Queen) in the order how Squark opened them. Note that the second line is a blank line if m = 0.
输出解释
For each test case, output 2n - 1 lines, each containing a real number representing the probability of each possible result in the order as described above. Your answer is considered to be correct if and only if it satisfies at least one of the two conditions below.

1.The absolute error is at most 10-12;

2.The relative error is at most 10-9.
输入样例
2
2 4
2 2 2 2
2 0
输出样例
0.0000000000000
1.0000000000000
0.5000000000000
0.5000000000000
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5070

最后修改于 2020-10-25T23:19:27+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)