CF2115C.Gellyfish and Eternal Violet

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn monsters, numbered from 11 to nn, in front of Gellyfish. The HP of the ii-th monster is hih_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 11.

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

  1. The Sword Sharpened with Tears shines with a probability of pp.
  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 11.
    • 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 11.

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.

前方有 nn 只怪物,编号从 11 到 nn,第 ii 只怪物的生命值(HP)为 hih_i。

Gellyfish 并不想杀死它们,但她希望确保这些怪物不会对她构成威胁。因此,她希望将所有怪物的 HP 恰好降至 11。

现在,Gellyfish 将使用「以泪淬炼之剑」对怪物发起 mm 轮攻击。每轮中:

  1. 「以泪淬炼之剑」以概率 pp 发出光芒;
  2. Gellyfish 可选择是否发动攻击:
    • 若 Gellyfish 不发动攻击,则不发生任何事;
    • 若 Gellyfish 选择发动攻击,且「以泪淬炼之剑」发出光芒,则所有怪物的 HP 同时减少 11;
    • 若 Gellyfish 选择发动攻击,但「以泪淬炼之剑」未发出光芒,则 Gellyfish 可任选一只怪物,将其 HP 减少 11。

请注意:在 Gellyfish 决定是否发动攻击之前,她已知晓该轮中宝剑是否发光;此外,当宝剑发光时,Gellyfish 只能对所有怪物同时发动攻击,而不能仅针对某一只怪物发动攻击。

现在,Gellyfish 想知道:若她在战斗中始终做出最优决策,那么最终达成目标(即所有怪物 HP 恰好为 11)的概率是多少?

输入格式

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

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

The second line of each test case contains nn integers h1,h2,…,hnh_1,h_2,\ldots,h_n (1≤hi≤4001 \leq h_i \leq 400) — the HP of the monsters.

It is guaranteed that the sum of nn over all test cases does not exceed 100100.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是各测试用例的描述。

每个测试用例的第一行包含三个整数 nn、mm 和 p′p'(1≤n≤201 \leq n \leq 20,1≤m≤40001 \leq m \leq 4000,0≤p′≤1000 \leq p' \leq 100)——分别表示怪物数量、攻击轮数,以及一个整数 $p' $,用于表示“泪之淬炼之剑”闪耀的概率 p=p′100p = \frac {p'} {100}。

每个测试用例的第二行包含 nn 个整数 h1,h2,…,hnh_1,h_2,\ldots,h_n(1≤hi≤4001 \leq h_i \leq 400)——表示各怪物的生命值(HP)。

保证所有测试用例中 nn 的总和不超过 100100。

输出格式

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−610^{-6}.

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

对于每个测试用例,输出一个实数,表示水母(Gellyfish)达成目标的概率。

若你的答案的绝对误差或相对误差不超过 10−610^{-6},则视为正确。

形式化地,设你的答案为 aa,评测组的答案为 bb。当且仅当 ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6} 时,你的答案被接受。

输入输出样例

  • 输入#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

    输出#1

    0.910000
    0.672320
    0.588099
    0.931474

说明/提示

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 11 in the first round. For the second round:

  • If the sword shines, since monster 11 was attacked in the first round, Gellyfish can't reach her goal.
  • Otherwise, Gellyfish can attack monster 22, allowing her to reach her goal.

Therefore, the probability that Gellyfish can reach her goal is 10%+(90%⋅90%)=91%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 55 rounds. The probability that Gellyfish can reach her goal is 100%−(80%)5=67.232%100\% - (80\%)^5 = 67.232\%.

在第一个测试用例中,无论第一轮中剑是否发光,水母怪都会发动攻击。

如果第一轮中剑发光,则水母怪在第一轮攻击后即可达成目标。

否则,若第一轮中剑不发光,她将在第一轮攻击怪物 11。进入第二轮时:

  • 若剑发光,由于怪物 11 已在第一轮被攻击过,水母怪无法达成目标;
  • 若剑不发光,水母怪可攻击怪物 22,从而达成目标。

因此,水母怪能够达成目标的概率为 10%+(90%⋅90%)=91%10\% + (90\% \cdot 90\%) = 91\%。

在第二个测试用例中,水母怪仅在第一轮剑发光时才会发动攻击。可以观察到,水母怪无法达成目标的唯一情况是:全部 55 轮中剑均未发光。因此,水母怪能够达成目标的概率为 100%−(80%)5=67.232%100\% - (80\%)^5 = 67.232\%。

输入解题思路,AI测评打分。不知道怎么写?

首页