QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#5740. 测试对象通常会死

統計

你在一间陌生的房间里醒来,一个机器人的声音向你问候。你遇到麻烦了。

这个声音解释说,你正是一系列伦理上有问题的实验的对象。你现在正在进行的测试如下:人工智能(AI)从 $1$ 到 $n$ 中选取一个整数,其中数字 $k$ 被选中的概率为 $\frac{p_k}{p_1 + \dots + p_n}$。你需要猜出这个数字。

如果你猜错了,你会被送去睡觉,你的记忆会被抹除,然后你将再次参加同样的测试。有 $c$ 的百分比概率,AI 会按照同样的程序重新选取数字;有 $100 - c$ 的百分比概率,数字将保持不变。

你不知道自己已经参加过多少次这个测试,也不知道之前选过什么数字,但你显然希望尽可能少花时间。因此,你将选择一个概率分布 $q_1, \dots, q_n$,并以概率 $q_k$ 猜出数字 $k$。

在完成测试之前,你需要进行的猜测次数的最小期望值是多少?

输入格式

第一行包含两个整数 $n$ 和 $c$ ($2 \le n \le 10^5$, $0 \le c \le 100$)。

第二行包含 $n$ 个整数 $p_1, \dots, p_n$ ($1 \le p_i \le 10^3$)。

输出格式

输出一个浮点数,即最小可能的猜测次数期望值。

如果你的答案的绝对误差或相对误差不超过 $10^{-6}$,则被视为正确。

样例

样例输入 1

4 100
25 25 25 25

样例输出 1

4

样例输入 2

2 0
1 4

样例输出 2

1.800000000

说明

对于本题,概率分布是一个实数序列 $q_1, \dots, q_n$,满足 $0 \le q_i$ 且 $q_1 + \dots + q_n = 1$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.