#C1479. Toys Assembly Line
Toys Assembly Line
Toys Assembly Line
In the Toys Assembly Line problem, you are given a linear sequence of stations. Each station, except for the first one, is reached from the previous station with a given probability. Initially, all toys are at the first station. The expected number of toys that reach the final station is given by the product of the passing probabilities at each stage. Mathematically, if we denote the probabilities by ( p_1, p_2, \dots, p_{n-1} ), then the expected number of toys reaching the final station is:
[ E = \prod_{i=1}^{n-1} p_i ]
Your task is to compute this expected value given ( n ) (which is the total number of stations) and the ( n-1 ) probabilities for transitioning from one station to the next. The output should be rounded to two decimal places.
inputFormat
The first line of input contains an integer ( n ) representing the total number of stations. The second line contains ( n-1 ) space-separated real numbers, each representing the probability of a toy moving correctly from one station to the next.
outputFormat
Output a single line containing the expected number of toys that reach the final station, rounded to two decimal places.## sample
5
0.8 0.9 1.0 0.5
0.36