QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#12015. 撸猫

统计

作为一位喜欢猫的人,小B家里养了$n$只猫。这些猫从$1$到$n$标号。

他每天最喜欢的时候就是撸猫,可惜猫猫并不是每天都愿意被他撸。愿意被他撸的猫猫集合$S \subseteq [n]$ 根据某个概率分布 $P$ 随机而来。 在知道了哪些猫猫愿意被撸之后,小B可以选择某一只愿意的来rua。注意,如果$S$集合为空,则小B不能撸任何一只猫。同时,小B的撸猫策略可以带有随机性。比如,在知道了$1,2$号猫猫都愿意被撸之后,他可以以$50\%$的概率撸第一只猫,以另外$50\%$的概率撸第二只猫。

作为一位公平的人,小B希望给每一只猫猫更多被rua的机会。他希望设计一个撸猫的策略来最大化$\Pr[i \text{被撸} | i\in S]$的最小值。换句话说,令$p_i = \Pr[i\in S]$是第$i$只猫猫愿意被撸的概率。我们需要设计一个撸猫的策略来最大化常数$c$,使得每只猫被撸的概率至少是$c\cdot p_i$。

输入格式

第一行一个正整数$n$,表示猫猫的数量。

接下来一行,一共$2^n$个非负实数,描述一个概率分布$P$。 描述方式如下:

假设$x_i$是第$i$个实数。把$i-1$写成二进制的形式 $i -1 = (a_n a_{n-1} \dots a_1)_2$。 令$T_i = \{j ~|~ a_j = 1\}$,那么$x_i$就表示的是愿意被撸的猫猫集合恰好是$T_i$的概率。

举个例子,当$n=2$时,我们会使用四个非负实数来描述这个概率分布。其中第一个表示的是没有猫猫愿意被撸的概率。第二个数表示的是只有第一只猫猫愿意被撸的概率。第三个数表示的是只有第二只猫猫愿意被撸的概率。第四个数表示的是两只猫猫都愿意被撸的概率。

保证$x_1 \neq 1$。由于输入精度原因,保证$1-10^{-6} \le \sum x_i\le 1 + 10^{-6}$。

输出格式

输出一行一个实数,表示最大的常数$c$。

你的输出被认为正确当且仅当与标准答案的绝对误差或者相对误差不超过$10^{-6}$。

样例数据

样例 1 输入

2
0.25 0.25 0.25 0.25

样例 1 输出

0.75

样例 1 解释

在第一个样例中,小B的最优撸猫策略如下:当只有一只猫可以撸的时候,他就一定会去撸那只猫。当两只猫都可以撸的时候,他会等概率地摸这两只猫。

因此,每只猫被摸的概率就是$\frac{1}{4} + \frac{1}{4} \times \frac{1}{2} = \frac{3}{8}$。而每只猫愿意被摸的概率是$\frac{1}{4} + \frac{1}{4} = \frac{1}{2}$。因此,最优的常数$c = \frac{3}{8} / 0.5 = \frac{3}{4}$。

样例 1 输入

3
0.12 0.18 0.02 0.1 0.1 0.05 0.15 0.28

样例 1 输出

0.5057471264

子任务

注意本题读入量较大。我们保证标程使用的是scanf来读入所有数字,并且标程在读入上所花时间不超过$250$ms。

Subtask 1 [12 pts]: $1\le n \le 2$.

Subtask 2 [18 pts]: $1\le n \le 7$.

Subtask 3 [10 pts]: $1\le n \le 10$.

Subtask 4 [35 pts]: $1\le n\le 15$.

Subtask 5 [25 pts]: $1\le n\le 20$.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.