CF623D.Birthday
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A MIPT student named Misha has a birthday today, and he decided to celebrate it in his country house in suburban Moscow. n friends came by, and after a typical party they decided to play blind man's buff.
The birthday boy gets blindfolded and the other players scatter around the house. The game is played in several rounds. In each round, Misha catches exactly one of his friends and has to guess who it is. The probability of catching the i-th friend does not change between rounds and is equal to p__i percent (as we know, it is directly proportional to the amount of alcohol consumed by the i-th friend) and _p_1 + _p_2 + ... + p__n = 100 holds. Misha has no information about who he caught. After Misha makes an attempt to guess the caught person, the round ends. Even then, Misha isn't told whether he guessed correctly, and a new round begins.
The game ends when Misha guesses every friend at least once, that is, there exists such set of rounds _k_1, _k_2, ..., k__n, that during round number k__i Misha caught the i-th friend and guessed him. Misha wants to minimize the expectation of the number of rounds of the game. Despite the fact that at any point in the game Misha has no information about who he has already guessed, his friends are honest, and if they see that the condition for the end of the game is fulfilled, the game ends immediately. Find the expectation of the number of rounds in the game if Misha plays optimally.
今天是莫斯科物理技术学院(MIPT)的一名学生米沙的生日,他决定在莫斯科郊区的乡间别墅庆祝。共有 n 位朋友前来参加聚会,典型的派对结束后,大家决定玩“蒙眼抓人”游戏。
生日主角米沙被蒙上眼睛,其余玩家则分散在房子里各处。游戏分若干轮进行。每轮中,米沙恰好抓住一位朋友,并需猜出此人是谁。抓到第 i 位朋友的概率在各轮中保持不变,为 pi 百分比(众所周知,该概率与第 i 位朋友所摄入的酒精量成正比),且满足 p1+p2+⋯+pn=100。米沙在抓人后并不知道抓到了谁。他在尝试猜测被抓者身份后,本轮即告结束;即便此时米沙仍未被告知猜测是否正确,下一轮也随即开始。
当米沙对每位朋友都至少成功猜中过一次时,游戏结束。换言之,存在一组轮次编号 k1,k2,…,kn,使得在第 ki 轮中,米沙恰好抓到了第 i 位朋友并成功猜中了他。米沙希望最小化游戏总轮数的期望值。尽管在游戏任意时刻,米沙均无法获知自己此前已猜中过哪些人,但他的朋友们诚实可信:一旦他们观察到游戏结束条件已被满足,游戏便立即终止。若米沙采取最优策略,求游戏总轮数的期望值。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of Misha's friends.
The second line contains n integers p__i (
), giving the probability to catch the i-th friend in one particular round in percent.
输入的第一行包含一个整数 n(1 ≤ n ≤ 100)—— 表示米沙的朋友数量。
第二行包含 n 个整数 pi(
),表示在某一轮中抓住第 i 个朋友的概率(以百分比为单位)。
输出格式
Print a single real value — the expectation of the number of rounds provided that Misha plays optimally. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if
.
输出一个实数——即在米沙采取最优策略的前提下,回合数的期望值。若你的答案的绝对或相对误差不超过 10−6,则视为正确。
具体而言:假设你的答案为 a,而裁判组的答案为 b。当且仅当
时,评测程序将判定你的答案正确。
输入输出样例
输入#1
2 50 50
输出#1
5.0000000000
输入#2
4 50 20 20 10
输出#2
39.2846263444
说明/提示
The optimal strategy in the first sample is to guess friends alternately.
第一个样例中的最优策略是交替猜测朋友。
输入解题思路,AI测评打分。不知道怎么写?