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

建议使用的浏览器:

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

6248:Fair Lottery

Special Judge 特殊评判
题目描述
There is a lottery going to happen among $N$ groups of people. Group $i$ consists of $a_i$ persons. In the end, at most $M$ persons will be the winner of this lottery.
There is one extra restriction for this lottery: for each group, either all or none of the person in this group
are winners. In other words, no partial winners allowed for each group.
A lottery program is defined as a set of outcomes. The outcome announces the winners of the lottery. Each outcome has it’s own probability to happen, and the sum of probabilities among all outcomes equals to 1.0.
A fair lottery program is a lottery program that makes each person having the same probability $p$ of winning the lottery. Find the maximum probability $p$ over all fair lottery programs.
For example, suppose there are 3 groups: $A$, $B$, and $C$, each consists of 1, 2, and 2 persons. At most 3 persons will be the winner of the lottery.
One possible fair lottery program is: it consists of only one outcome that no one wins. So each person has the same probability of 0% winning the lottery.
A better fair lottery program is: there are two outcomes, each happening with probability of 50%. Outcome 1 announces person in group A and B as winners; and outcome 2 announces person in group C as winners.
Hence each person having the winning probability of 50%. It’s easy to verify that 50% is the maximum probability over all lottery programs.
输入解释
The first line of the input gives the number of test cases, $T$. $T$ test cases follow.
Each test case contains 2 lines, the first line consists of 2 numbers $N$, $M$ indicating the number of groups and the max number of lottery winners.
The second line consists of $N$ numbers $a_1, a_2, . . . , a_N$ indicating the number of persons in each group.
$1 \leq T \leq 100$
$1 \leq N \leq 10$
$1 \leq M \leq 100$
$1 \leq a_i \leq 100$
输出解释
For each test case, output one line containing “Case #x: y”, where $x$ is the test case number (starting from 1) and $y$ is the maximum probability $p$ for each one to be the winner over all fair lottery programs. $y$ will be considered correct if it is within an absolute or relative error of $10^{-6}$ of the correct answer.
输入样例
2
3 3
1 2 2
4 2
1 1 1 2
输出样例
Case #1: 0.5000000000
Case #2: 0.4000000000
提示
The first test case is the sample in the problem.
In the second test case, the best lottery program is: Assume groups are A(1), B(1), C(1), D(2), For [0, 0.2) persons in A, B are the winners. 
For [0.2, 0.4) persons in B, C are the winners. For [0.4, 0.6) persons in A, C are the winners. For [0.6, 1) persons in D are the winners.
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6248

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

共提交 0

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