Problem:
 Score : 100 points    Problem Statement Let N be a positive odd number.  There are N coins, numbered 1, 2, \ldots, N .
For each i ( 1 \leq i \leq N ), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i .  Taro has tossed all the N coins.
Find the probability of having more heads than tails.      Constraints  N is an odd number.  1 \leq N \leq 2999  p_i is a real number and has two decimal places.  0 < p_i < 1         Input Input is given from Standard Input in the following format:  N  p_1  p_2  \ldots  p_N       Output Print the probability of having more heads than tails.
The output is considered correct when the absolute error is not greater than 10^{-9} .        Sample Input 1 3
0.30 0.60 0.80      Sample Output 1 0.612  The probability of each case where we have more heads than tails is as follows:   The probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144 ;  The probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336 ;  The probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096 ;  The probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036 .   Thus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612 .       Sample Input 2 1
0.50      Sample Output 2 0.5  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

Solution (Python):
n = int(input())
p = list(map(float, input().split()))


dp = [[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 1.0
for i in range(1,n+1):
    k = p[i-1]
    for j in range(i+1):
        
        
        if j > 0:
            dp[i][j] += (dp[i-1][j-1] * k) + (dp[i-1][j] * (1 - k))
        else:
            dp[i][j] += dp[i-1][j] * (1 - k)
ans = 0
for i in range(n+1):
    if (n - i) < i:
        ans += dp[-1][i]
print(ans)

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

N = iin()
p = fln()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1-p[i])
ans = 0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def add_mod(a,b): return (a+b) % MOD

N = iin()
p = fln()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j] * (1-p[i])
        dp[i+1][j+1] += dp[i][j] * p[i]
ans = 0.0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
MOD = 10**9+7

N = iin()
p = fln()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

dp[0][0] = 1
for i in range(N):
    for j in range(N):
        dp[i+1][j+1] += dp[i][j]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])
ans = 0.0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)

Solution (Python):
def solve(N, probs):
  
  
  dp = [0 for _ in range(N + 1)]
  dp[0] = 1

  for toss_id in range(1, N + 1):
    head_prob = probs[toss_id - 1]
    tail_prob = 1.0 - probs[toss_id - 1]
    
    for j in range(toss_id, -1, -1):
      
      if j == 0:
        dp[j] = dp[j] * tail_prob
      else:
        dp[j] = (dp[j] * tail_prob) + (dp[j - 1] * head_prob)

  
  ans = sum(dp[N // 2 + 1:])
  print(ans)


def iin(): return int(input())
def fln(): return list(map(float, input().split()))


N = iin()
probs = fln()
solve(N, probs)

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
MOD = 10**9+7

N = iin()
p = fln()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1.0

for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1.0-p[i])
ans = 0.0
for i in range((N+1)//2, N+1):
    ans += dp[N][i]
print(ans)

Solution (Python):
def solve():
    N, *p = map(float, open(0).read().split())
    N = int(N)

    dp = [[0] * (N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * p[i]
            dp[i+1][j] += dp[i][j] * (1 - p[i])

    ans = 0
    for i in range((N+1) // 2, N+1):
        ans += dp[N][i]
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
prob_table = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1
for i in range(0,N):
	for j in range(i+1):
		dp[i+1][j+1] += dp[i][j]*prob_table[i]
		dp[i+1][j] += dp[i][j]*(1-prob_table[i])

print(sum(dp[N][N//2+1:]))

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
prob_table = list(map(float, input().split()))

dp = [[0 for _ in range(2*N+2)] for _ in range(N)]


dp[0][N-1] = 1 - prob_table[0]
dp[0][N+1] =   prob_table[0]

for i in range(1,N):
	for j in range(N-i-1,N+i+2):
		if(j > 0 and j < 2*N+1):
			dp[i][j] = dp[i-1][j-1]*prob_table[i] + dp[i-1][j+1]*(1-prob_table[i])
		elif(j <= 0):
			dp[i][j] = dp[i-1][j+1]*(1-prob_table[i])
		else : 
			dp[i][j] = dp[i-1][j-1]*prob_table[i]
print(sum(dp[N-1][N+1:]))

Solution (Python):



n = int(input())
lst1 = list(map(float,input().split()))


dp = [[0.0]*(n+1) for _ in range(n+1)] 
dp[0][0] = 1.0 






"""
図にするとこんなかんじ
    0回表,1回表,2回表...
0枚目[[1.0, 0.0, 0.0, 0.0],
1枚目[0.7, 0.3, 0.0, 0.0], 
2枚目[0.28, 0.54, 0.18, 0.0],
3枚目[0.056, 0.33, 0.468, 0.144]] 
"""
for i in range(1,n+1):
    for j in range(i+1): 
        dp[i][j] = dp[i-1][j]*(1-lst1[i-1]) 
        if j > 0: 
            dp[i][j] += dp[i-1][j-1]*lst1[i-1] 




ans = 0.0
for i in range((n+1)//2,n+1): 
    ans += dp[-1][i]
print(ans)

Solution (Python):



n = int(input())
lst1 = list(map(float,input().split()))


dp = [[0.0]*(n+1) for _ in range(n+1)] 
dp[0][0] = 1.0 






"""
図にするとこんなかんじ(1列目は実際に起きる数字ではない)
[[1.0, 0.0, 0.0, 0.0],
[0.7, 0.3, 0.0, 0.0], 
[0.28, 0.54, 0.18, 0.0],
[0.056, 0.33, 0.468, 0.144]] 
"""
for i in range(1,n+1):
    for j in range(i+1):
        dp[i][j] = dp[i-1][j]*(1-lst1[i-1])
        if j > 0:
            dp[i][j] += dp[i-1][j-1]*lst1[i-1]




ans = 0.0
for i in range((n+1)//2,n+1): 
    ans += dp[-1][i]
print(ans)

Solution (Python):
n = int(input())
a = list(map(float,input().split()))
dp = [[0 for i in range(n)] for i in range(n//2+1)]
for i in range((n//2)+1):
    l,j=1,i
    while j<n:
        if i==0:
            l=l*a[j]
            dp[i][j]=l
            j=j+1
        else:
            for k in range(i):
                l=l*(1-a[k])
                dp[i][k]=l
            while j<n:
                dp[i][j]=(dp[i-1][j-1]*(1-a[j]))+(dp[i][j-1]*a[j])
                j=j+1
l=0
for i in range(n//2+1):
    l+=dp[i][n-1]
print(l)

Solution (Python):
n=int(input())
p=list(map(float,input().split()))
dp=[[0 for j in range(n+1)] for i in range(n+1)]

dp[0][0]=1
for i in range(n):
  for j in range(i+1):
    dp[i+1][j+1]+=dp[i][j]*p[i]
    dp[i+1][j]+=dp[i][j]*(1-p[i])
ans=0
for i in range(n,-1,-1):
  if i>n-i:
    ans+=dp[-1][i]
  else:
    break
print(ans)

Solution (Python):
N = int(input())
P = [float(p) for p in input().split()]

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j]*(1-P[i])
        dp[i+1][j+1] += dp[i][j]*P[i]

ans = 0
for j in range(N//2+1, N+1):
    ans += dp[N][j]

print(ans)

Solution (Python):
n=int(input())
p=list(map(float,input().split()))
dp=[[0 for j in range(n+1)] for i in range(n+1)]

dp[0][0]=1
for i in range(n):
  for j in range(n):
    dp[i+1][j+1]+=dp[i][j]*p[i]
    dp[i+1][j]+=dp[i][j]*(1-p[i])
ans=0
for i in range(n,-1,-1):
  if i>n-i:
    ans+=dp[-1][i]
  else:
    break
print(ans)

Solution (Python):
import numpy as np

N = int(input())
P = list(map(float, input().split()))

dp = np.zeros(N+1)
dp[0] = 1

for i in range(1, N+1):
  dp[1:] = dp[:-1]*P[i-1] + dp[1:]*(1-P[i-1])

print(dp[(N+1)//2])

Solution (Python):
N = int(input())
P = [0.0] + list(map(float, input().split()))

dp = [[0.0 for _ in range(3002)] for _ in range(3002)]
dp[0][0] = 1

for i in range(1, N + 1):
  for j in range(3000):
    dp[i][j] = dp[i - 1][j - 1] * P[i] + dp[i - 1][j] * (1 - P[i])

answer = 0
for  j in range(N // 2 + 1, 3002):
  answer += dp[N][j]

print(answer)

Solution (Python):
import numpy as np
n = int(input())
p = list(map(float, input().split()))

dp = np.zeros(len(p)+1)
dp[0] = 1 - p[0]
dp[1] = p[0]

for i in range(1, len(p)):
    ura = dp * (1 - p[i])
    omote = np.append(np.zeros(1), dp[:-1] * p[i])
    dp = ura + omote

print(np.sum(dp[len(p)//2+1:]))

Solution (Python):
N = int(input())
P = list(map(float, input().split()))

dp = [[1] + [0]*N for i in range(N+1)]
for i in range(1, N+1):
  for j in range(1, i+1):
    dp[i][j] = dp[i-1][j-1]*(P[i-1]) + dp[i-1][j]*(1-P[i-1])

print(dp[-1][(N+1)//2])

Solution (Python):
def task(probs):
    n = len(probs)
    dp = [0] * (n + 1)
    dp[0] = 1

    for i, p in enumerate(probs, start=1):
        state = 0
        for j in range(i + 1):
          
          curr = dp[j]
          dp[j] = (curr * (1 - p)) + state
          state =  curr * p

    return sum(dp[(n + 1) // 2:])


n = input()  
probs = [float(x) for x in input().split()]
print(task(probs))

Solution (Python):
def coins(probabilities):
    n = len(probabilities)
    res = [0] * (n + 1)
    res[0] = 1

    for i, p in enumerate(probabilities, start=1):
        q = 1 - p
        carry = 0
        for j in range(i + 1):
            res[j], carry = res[j] * q + carry, res[j] * p

    return sum(res[(n + 1) // 2:])


def main():
    input()  
    probabilities = [float(x) for x in input().split()]
    return coins(probabilities)


print(main())

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = list(map(float,input().split()))
dp = [[0] * (n+5) for i in range(n+5)]
dp[0][0] = 1
for i in range(n):
    for j in range(n+1):
        if j == 0:
            dp[i+1][j] = dp[i][j] * (1-a[i])
            continue
        dp[i+1][j] = dp[i][j-1] * a[i] + dp[i][j] * (1-a[i])
print(sum(dp[n][n//2+1:]))

Solution (Python):
n = int(input())
p = [float(x) for x in input().split()]

dp = [[0 for _ in range(n+1)] for __ in range(n+1)]

dp[0][0] = 1

for i in range(1,n+1):
    for j in range(i+1):
        if j == 0:
            dp[i][j] = (1-p[i-1])*dp[i-1][j]
        else:
            dp[i][j] = (1-p[i-1])*dp[i-1][j] + p[i-1]*dp[i-1][j-1]

print(sum(dp[n][(n+1)//2:]))

Solution (Python):
def wolne_mnozenie_wielomianu(wielomian1, wielomian2):
    odp = [0.0] * (len(wielomian1) + len(wielomian2) - 1)
    for i in range(len(wielomian1)):
        for j in range(len(wielomian2)):
            odp[i + j] += wielomian1[i] * wielomian2[j]
    while len(odp) > 1 and odp[-1] == 0.0:
        odp.pop()
    return odp

def wyrownaj(wielomian1, wielomian2):
    if len(wielomian1) > len(wielomian2):
        wielomian2 = wielomian2 + [0.0] * (len(wielomian1) - len(wielomian2))
    if len(wielomian2) > len(wielomian1):
        wielomian1 = wielomian1 + [0.0] * (len(wielomian2) - len(wielomian1))
    return wielomian1, wielomian2

def dodawanie_wielomianu(wielomian1, wielomian2):
    wielomian1, wielomian2 = wyrownaj(wielomian1, wielomian2)
        
    odp = [0.0] * len(wielomian2)
    for i in range(len(wielomian1)):
        odp[i] = wielomian1[i] + wielomian2[i]
    while len(odp) > 1 and odp[-1] == 0.0:
        odp.pop()
    return odp

def odejmowanie_wielomianu(wielomian1, wielomian2):
    wielomian1, wielomian2 = wyrownaj(wielomian1, wielomian2)
        
    odp = [0.0] * len(wielomian2)
    for i in range(len(wielomian1)):
        odp[i] = wielomian1[i] - wielomian2[i]
    while len(odp) > 1 and odp[-1] == 0.0:
        odp.pop()
    return odp

def szybkie_mnozenie_wielomianu(wielomian1, wielomian2):
    wielomian1, wielomian2 = wyrownaj(wielomian1, wielomian2)
    if len(wielomian1) < 3:
        return wolne_mnozenie_wielomianu(wielomian1, wielomian2)
    k = len(wielomian1) // 2
    
    a = wielomian1[k:]
    b = wielomian1[:k]
    c = wielomian2[k:]
    d = wielomian2[:k]
    
    ac = szybkie_mnozenie_wielomianu(a, c)
    bd = szybkie_mnozenie_wielomianu(b, d)
    w = szybkie_mnozenie_wielomianu(dodawanie_wielomianu(a, b), dodawanie_wielomianu(c, d))
    w_ac_bd = odejmowanie_wielomianu(w, dodawanie_wielomianu(ac, bd))
    
    ac = [0.0] * 2 * k + ac
    w_ac_bd = [0.0] * k + w_ac_bd
    
    odp = dodawanie_wielomianu(ac, dodawanie_wielomianu(bd, w_ac_bd))
    while len(odp) > 1 and odp[-1] == 0.0:
        odp.pop()
    return odp
  

def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def wczytaj_rzeczywiste():
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(float(element))
    return ostateczna_lista

def wymnoz_duzo_wielomianow(wielomiany):
    if len(wielomiany) == 1:
        return wielomiany[0]
    
    k = (len(wielomiany) + 1) // 2
    lewo = wymnoz_duzo_wielomianow(wielomiany[:k])
    prawo = wymnoz_duzo_wielomianow(wielomiany[k:])
    
    return szybkie_mnozenie_wielomianu(lewo, prawo)

def rzuc_grosza_wiedzminowi_natychmiast():
    N = wczytaj_liste()[0]
    prawdopodopienstwa = wczytaj_rzeczywiste()
    rzuty = []
    for moneta in prawdopodopienstwa: 
        rzut = [1 - moneta, moneta]
        rzuty.append(rzut)
    
    po_rzutach = wymnoz_duzo_wielomianow(rzuty)
    
    odp = sum(po_rzutach[N//2+1:])
    print(odp)
    
rzuc_grosza_wiedzminowi_natychmiast()

Solution (Python):
N, = map(int, input().split())
Ps = map(float, input().split())
dp = [0]*((N+1)**2)
dp[0] = 1
for i, p in enumerate(Ps):
    for j in range(N+1):
        dp[(i+1)*(N+1)+j] = p*dp[i*(N+1)+j-1] + (1-p)*dp[i*(N+1)+j]
r = 0
for i in range(N, N//2, -1):
    r += dp[N*(N+1)+i]
print(r)

Solution (Python):
N, = map(int, input().split())
Ps = map(float, input().split())
dp = [[0]*(N+1)for _ in range(N+1)]
dp[0][0] = 1
for i, p in enumerate(Ps):
    for j in range(N+1):
        dp[i+1][j] = p*dp[i][j-1] + (1-p)*dp[i][j]
r = 0
for i in range(N, N//2, -1):
    r += dp[N][i]
print(r)

Solution (Python):
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def wczytaj_rzeczywiste():
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(float(element))
    return ostateczna_lista

def rzuc_grosza_wiedzminowi_migusiem():
    N = wczytaj_liste()[0]
    prawdopodopienstwa = wczytaj_rzeczywiste()
    przed_rzutem = [1.0]
    for moneta in prawdopodopienstwa: 
        po_rzucie = []
        for i in range(len(przed_rzutem)):
            if i > 0: 
                po_rzucie.append(przed_rzutem[i]*(1-moneta)+przed_rzutem[i-1]*(moneta))
            else:
                po_rzucie.append(przed_rzutem[0]*(1-moneta))
        po_rzucie.append(przed_rzutem[-1]*moneta)
        przed_rzutem = po_rzucie
    odp = sum(przed_rzutem[N//2+1:])
    print(odp)
    
rzuc_grosza_wiedzminowi_migusiem()

Solution (Python):

N = int(input())
Ps = list(map(float, input().split()))


probs = [[0 for _ in range(N+1)] for _ in range(N)]

probs[0][1] = Ps[0]
probs[0][0] = 1 - Ps[0]



for i in range(1, N):
  for k in range(0, N+1):
    if k == 0:
      probs[i][k] = probs[i-1][k]*(1-Ps[i])
    else:
      probs[i][k] = probs[i-1][k-1]*Ps[i] + probs[i-1][k]*(1-Ps[i])



sum_all = sum(probs[N-1])
sum_ok = 0

start = int(N/2) + 1
for i in range(start, N+1):
  sum_ok += probs[N-1][i]

print(sum_ok / sum_all)

Solution (Python):
n = int(input())
p = list(map(float, input().split()))

dp = [[0] * (n+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(1,n+1):
    dp[i][0] = dp[i-1][0] * (1- p[i-1])
    for j in range(1,n+1):
        dp[i][j] = (dp[i-1][j] * (1- p[i-1]) +
                    dp[i-1][j-1] * p[i-1])

ans = 0
for i in range((n//2 + 1) , n+1):
    ans += dp[n][i]

print(ans)

Solution (Python):
def main():
    N = int(input())
    P = [float(x) for x in input().split()]
    over = (N + 1) // 2
    dp = [[0.0] * (over + 1) for _ in range(N + 1)]
    dp[0][0] = 1.0
    for i in range(N):
        for j in range(over):
            dp[i+1][j] += dp[i][j] * (1 - P[i])
            dp[i+1][j+1] += dp[i][j] * P[i]
        dp[i+1][over] += dp[i][over]
    print("{:.20f}".format(dp[-1][-1]))


if __name__ == '__main__':
    main()

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, p: "List[float]"):
    
    prob = [[0]*(N+1) for _ in range(N+1)]
    prob[0][0] = 1
    for i in range(N):
        for j in range(N+1):
            prob[i+1][j] = prob[i][j]*(1-p[i])
            if j-1 >= 0:
                prob[i+1][j] += prob[i][j-1]*p[i]
    print(sum(prob[N][N//2+1:]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    p = [float(next(tokens)) for _ in range(N)]  
    solve(N, p)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(n+1):
        if j-1 < 0:
            dp[i+1][j] = (1 - p[i]) * dp[i][j]
        else:
            dp[i+1][j] = p[i] * dp[i][j-1] + (1 - p[i]) * dp[i][j]

print(sum(dp[n][(n+1)//2:]))

Solution (Python):
n = int(input())
P = list(map(float, input().split()))
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
  for j in range(n+1):
    if j==0:
      dp[i+1][j] = dp[i][j]*(1-P[i])
    else:
      dp[i+1][j] = dp[i][j-1]*P[i] + dp[i][j]*(1-P[i])
print(sum(dp[n][1+n//2:]))

Solution (Python):
from math import ceil

N = int(input())
p = [float(i) for i in input().split()]


dp = [[0] * (N+1) for _ in range(N+1)]


dp[0][0] = 1.0


for i in range(N):
    for j in range(i+1):
        
        dp[i+1][j+1] += dp[i][j] * p[i]
        
        dp[i+1][j] += dp[i][j] * (1-p[i])

answer = 0.0
for i in range(ceil(N/2),N+1):
    answer += dp[N][i]

print(answer)

Solution (Python):
n = int(input())
p = list(map(float, input().split()))
q=[]
q.append([1])
for i in range(n):
    q[0].append(0)
prod = 1.0
for i in range(1,n+1):
    prod*=p[i-1]
    q.append([prod])

for i in range(1,n+1):
    for j in range(1,n+1):
        try:
            q[i].append(p[i-1]*q[i-1][j] + (1-p[i-1])*q[i-1][j-1])
        except:
            print(i)
            print(j)
        
ans = 0.0
for i in range(0,(n-1)//2+1):
    ans+=q[n][i]
print(ans)

Solution (Python):
N = int(input())
p = list(map(float, input().split()))

dp = []
for i in range(N+1):
	z = []
	for j in range(N):
		z.append(0)
	dp.append(z)

dp[0][0] = 1-p[0]

for i in range(N-1):
	dp[0][i+1] = dp[0][i]*(1-p[i+1])

dp[1][0] = p[0]

for i in range(N+1):
	for j in range(N-1):
		if j >= i-1 :
			dp[i+1][j+1]=p[j+1]*dp[i][j] + (1-p[j+1])*dp[i+1][j]
k = (N//2)+1
sump = 0
while(k<=N):
	sump += dp[k][N-1]
	k+=1
print(sump)

Solution (Python):
n = int(input())
p = [float(x) for x in input().split()]
dp = []
for i in range(n+1):
    tp = []
    for j in range(n+1):
        tp.append(0)
    dp.append(tp)
dp[0][1] =  p[0]
dp[0][0] = 1-p[0]
for i  in range(n):
    if i<=0:
        continue
    dp[i][0] = dp[i-1][0]*(1-p[i])
    for j in range(i+1):
        dp[i][j+1] = dp[i-1][j]*p[i]
        dp[i][j+1] += dp[i-1][j+1]*(1-p[i])

k = int(n/2)+1
ans = 0

for j in range(k, n+1):
    ans += dp[n-1][j]
print(ans)

Solution (Python):



def main():
    n = int(input())
    p = list(map(float, input().split()))
    dp = [[0 for _ in range(n + 100)] for _ in range(n + 100)]

    
    dp[0][0] = 1.0

    
    
    
    
    
    
    for i in range(n):
        for j in range(i + 1):
            
            dp[i + 1][j + 1] += dp[i][j] * p[i]
            
            dp[i + 1][j] += dp[i][j] * (1 - p[i])

    ans = 0

    
    for j in range((n + 1) // 2, n + 1):
        ans += dp[n][j]

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
probs = [float(c) for c in input().split()]

dp = [0] * (n+1)
dp[0] = 1
for coin in range(n):
    for heads in reversed(range(n+1)):
        dp[heads] = dp[heads] * (1 - probs[coin-1])
        if heads > 0:
            dp[heads] += dp[heads-1] * probs[coin-1]

ans = 0
for heads in range(n+1):
    tails = n - heads
    if heads > tails:
        ans += dp[heads]

print(ans)

Solution (Python):
n = int(input())
probs = [float(c) for c in input().split()]

dp = [[0] * (n+1) for _ in range(n+1)]
dp[0][0] = 1
for coin in range(1, n+1):
    for heads in range(n+1):
        dp[coin][heads] = dp[coin-1][heads] * (1 - probs[coin-1])
        if heads > 0:
            dp[coin][heads] += dp[coin-1][heads-1] * probs[coin-1]

ans = 0
for i in range(n//2 + 1, n+1):
    ans += dp[n][i]

print(ans)

Solution (Python):
N = int(input())
P = list(map(float,input().split()))
P.insert(0,0)
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[1][0] = 1-P[1]
dp[1][1] = P[1]
for i in range(2,N+1):
    for j in range(N+1):
        dp[i][j] += dp[i-1][j]*(1-P[i])
        if j>=1:
            dp[i][j] += dp[i-1][j-1]*P[i]
cnt = 0
for i in range(N//2+1,N+1):
    cnt += dp[N][i]
print(cnt)