QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#15147. set / Bitwise OR

الإحصائيات

Initially, you have the number $0$. Every second, you randomly choose a number from the range $[0, 2^n-1]$ and perform a bitwise OR operation (the | operator in C++/C, or or in Pascal) with the number you currently hold.

The probability of choosing the number $i$ is $p[i]$. It is guaranteed that $0 \le p[i] \le 1$ and $\sum p[i] = 1$.

Calculate the expected number of seconds until the number you hold becomes $2^n-1$.

Input

The first line contains an integer $n$. The second line contains $2^n$ numbers, where the $i$-th number represents the probability of choosing $i-1$.

Output

Output a single number representing the answer. An absolute or relative error of at most $10^{-6}$ is acceptable.

If there is no solution, output INF.

Examples

Input 1

2
0.25 0.25 0.25 0.25

Output 1

2.6666666667

Input 2

2
1 0 0 0

Output 2

INF

Constraints

For $30\%$ of the data, $n \le 10$. For $60\%$ of the data, $n \le 15$. For $100\%$ of the data, $n \le 20$.

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.