Educational DP Contest AtCoder I - Coins

View as PDF

Points: 10
Time limit: 1.0s
Memory limit: 1G

Problem types

Let be a positive odd number.

There are coins, numbered . For each , when Coin is tossed, it comes up heads with probability and tails with probability .

Taro has tossed all the coins. Find the probability of having more heads than tails.

Constraints

• is an odd number.
• .
• is a real number and has two decimal places.

Input Specification

The first line will contain the integer .

The next line will contain floats, .

Output Specification

Print the probability of having more heads than tails. The output is considered correct when the absolute error is not greater than .

Sample Input 1

3
0.30 0.60 0.80

Sample Output 1

0.612

Explanation For Sample 1

The probability of each case where we have more heads than tails is as follows:

• The probability of having is ;
• The probability of having is ;
• The probability of having is ;
• The probability of having is ;

Thus, the probability of having more heads than tails is .

Sample Input 2

1
0.50

Sample Output 2

0.5

Explanation For Sample 2

Outputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.

Sample Input 3

5
0.42 0.01 0.42 0.99 0.42

Sample Output 3

0.3821815872