#P9443. [ICPC2021 WF] Hand of the Free Marked

[ICPC2021 WF] Hand of the Free Marked

题目描述

Example placement of cards for k=5k = 5

There is a fairly well-known mentalism trick known as the Fitch Cheney trick. From a deck of nn playing cards, kk are selected uniformly at random and given to an assistant while the magician is out of the room. The assistant places k1k-1 of the selected cards on a table, face up, and the single remaining card face down. The cards are placed in a single row with the face-down card at the end (see the picture for an example). The magician enters the room, looks at the cards on the table, and announces what the kthk^{th} card is, although its face is hidden. The trick is typically done with n=52n=52 and k=5k=5.

The assistant uses two ways of passing information to the magician. First, they can pick which one of the kk cards to keep hidden. Second, they can rearrange the other k1k-1 cards in a specific way. For the case n=52n=52 and k=5k=5 both techniques are needed, since there are only 2424 ways of rearranging four cards, which is not enough to reliably signal the fifth card. It is an interesting exercise to come up with a simple, easy-to-remember strategy for executing this trick, but right now you have another concern.

You were planning to perform this trick today, but just now you have learned that the deck has more cards than you expected. The trick may be impossible! In desperation, you have decided to cheat a little. You have mm distinguishable ways of marking the backs of the playing cards. You have marked the backs of all nn cards, allowing you to narrow down the possibilities for the kthk^{th} card. For example, if there are 66 cards marked with a particular method, and you see that the back of the kthk^{th} card is marked with that method, you know it must be one of those 66 cards.

Determine the probability that you will successfully guess the kthk^{th} card, assuming you and the assistant execute an optimal (but likely very complicated!) strategy.

输入格式

The input contains one line with several integers. The first integer gives kk (2k102 \leq k \leq 10), the number of cards that will be selected. The second integer gives mm (1m101 \leq m \leq 10), the number of ways of marking the cards. The line is completed by mm positive integers, giving the number of cards marked with each distinct method. The sum of these mm integers is nn (kn109k \leq n \leq 10^9), which is the size of the deck.

输出格式

Output the highest possible probability of guessing the kthk^{th} card correctly, accurate up to an absolute error of 10910^{-9}.

题目大意

简要题意

两个人 A,BA, B 玩一个游戏。规则如下 :

AAnn 张互不相同的牌. 它们的背面mm 种不同的样式, 第 ii 种牌有 aia_i 张. 二人都对这套牌非常了解. 保证 i=1mai=n\sum\limits^{m}_{i=1}{a_i} = n.

BBAA 不在场的情况下从中随机抽出 kk 张, 然后选择一张牌倒置在桌面上. 然后 BB 可以以任意顺序重新排列其他牌并在桌面上依次排开, 并将倒置的牌放在序列的末尾. AABB 可以在游戏之前约定通过其他牌的排列顺序传递的信息.

随后 AA 需要根据桌面上牌的排列和倒置牌的背面说出倒置的牌具体是哪一张. 双方的目标都是使 AA 说出正确的牌。

现在给定 m,aim, a_ikk, 求二人均采取最佳策略的情况下, AA 的成功率是多少.

输入格式

输入仅一行, 首先是两个整数 k,mk, m, 然后是 mm 个整数 aia_i.

输出格式

一行, 一个实数, 表示答案. 答案与标准答案的差不超过 10910^{-9} 即判为正确.

4 1 28

0.960000000000

3 3 5 12 3

0.854385964912