Codeforces Round 1028 (Div. 1)
C
Gellyfish and Eternal Violet
Codeforces
2700
原题
← BD →
翻译中…

There are $n$ monsters, numbered from $1$ to $n$, in front of Gellyfish. The HP of the $i$-th monster is $h_i$.

翻译中…

Gellyfish doesn't want to kill them, but she wants to keep these monsters from being a threat to her. So she wants to reduce the HP of all the monsters to exactly $1$.

翻译中…

Now, Gellyfish, with The Sword Sharpened with Tears, is going to attack the monsters for $m$ rounds. For each round:

翻译中…
  1. The Sword Sharpened with Tears shines with a probability of $p$.
  2. Gellyfish can choose whether to attack:
  • If Gellyfish doesn't attack, nothing happens.
    • If Gellyfish chooses to attack and The Sword Sharpened with Tears shines, the HP of all the monsters will be reduced by $1$.
    • If Gellyfish chooses to attack and The Sword Sharpened with Tears does not shine, Gellyfish can choose one of the monsters and reduce its HP by $1$.
翻译中…

Please note that before Gellyfish decides whether or not to attack, she will know whether the sword shines or not. Also, when the sword shines, Gellyfish can only make attacks on all the monsters and cannot make an attack on only one monster.

翻译中…

Now, Gellyfish wants to know what the probability is that she will reach her goal if she makes choices optimally during the battle.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $m$, and $p'$ ($1 \leq n \leq 20$, $1 \leq m \leq 4000$, $0 \leq p' \leq 100$) — the number of monsters, the number of rounds of attacks, and an integer representing the probability $p = \frac {p'} {100}$ that the Sword Sharpened with Tears shines.

翻译中…

The second line of each test case contains $n$ integers $h_1,h_2,\ldots,h_n$ ($1 \leq h_i \leq 400$) — the HP of the monsters.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $100$.

翻译中…

Output

翻译中…

For each test case, output a single real number representing the probability that Gellyfish will reach her goal.

翻译中…

Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.

翻译中…

Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.

翻译中…

Note

翻译中…

In the first test case, Gellyfish will always attack whether the sword shines or not in the first round.

翻译中…

If the sword shines in the first round, then Gellyfish can reach her goal after the attack in the first round.

翻译中…

Otherwise, if the sword does not shine in the first round, she will attack monster $1$ in the first round. For the second round:

翻译中…
  • If the sword shines, since monster $1$ was attacked in the first round, Gellyfish can't reach her goal.
  • Otherwise, Gellyfish can attack monster $2$, allowing her to reach her goal.
翻译中…

Therefore, the probability that Gellyfish can reach her goal is $10\% + (90\% \cdot 90\%) = 91\%$.

翻译中…

In the second test case, Gellyfish will only attack in the first round where the sword shines. It can be observed that the only way Gellyfish can't reach her goal is if the sword never shines in all $5$ rounds. The probability that Gellyfish can reach her goal is $100\% - (80\%)^5 = 67.232\%$.

翻译中…

样例

Input #1
4
2 2 10
2 2
5 5 20
2 2 2 2 2
6 20 50
1 1 4 5 1 4
9 50 33
9 9 8 2 4 4 3 5 3
Output #1
0.910000
0.672320
0.588099
0.931474
InputCopy OutputCopy
题目信息
题号
2115C
时间限制
2 s
内存限制
1024 MB
标签
组合数学
动态规划
贪心
数学
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。