PROBLEM STATEMENT
Bharat and Tom both love cricket but they support different teams. Bharat supports Indian Cricket Team and Tom supports Australian Cricket Team. Both are ready to bet on their favourite teams.
Both teams are about to play an N (N<2000) match bilateral series.
Let’s suppose that every match yields a result with no possibility for a draw and after the N match series India has won x matches and Australia has won y matches. India wins the series and Bharat wins the bet if x > y.
Australia wins the series and Tom wins the bet if y > x.
Note that x+y = N
You are provided with probability information of N matches that tells you the probability of India winning that match.
Find the probability that Bharat wins the bet. Input Input consists of two lines. First line contains the number N. Next N lines contain floating point numbers, Pi denoting the probability that India will win the i-th match
Constraints
N is an odd number and 1 < N < 2000 Pi gives the probability of India winning i-th match
0 <= Pi <= 1
Output
Print the probability of Bharat winning the bet.
Print exactly six digits after the decimal point.
Both teams are about to play an N (N<2000) match bilateral series.
Let’s suppose that every match yields a result with no possibility for a draw and after the N match series India has won x matches and Australia has won y matches. India wins the series and Bharat wins the bet if x > y.
Australia wins the series and Tom wins the bet if y > x.
Note that x+y = N
You are provided with probability information of N matches that tells you the probability of India winning that match.
Find the probability that Bharat wins the bet. Input Input consists of two lines. First line contains the number N. Next N lines contain floating point numbers, Pi denoting the probability that India will win the i-th match
Constraints
N is an odd number and 1 < N < 2000 Pi gives the probability of India winning i-th match
0 <= Pi <= 1
Output
Print the probability of Bharat winning the bet.
Print exactly six digits after the decimal point.
SOLUTION
This Java code reads the input values, initializes a 2D dynamic programming array (dp), and calculates the probability that Bharat wins the bet using the provided probabilities for each match. It then prints the result with six digits after the decimal point.
Compile and run this Java program, providing the input as described in the problem statement, and it will output the probability that Bharat wins the bet.
Compile and run this Java program, providing the input as described in the problem statement, and it will output the probability that Bharat wins the bet.