#Lutece1158. Game of OOXX
Game of OOXX
Migrated from Lutece 1158 Game of OOXX
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
One day, Bob was playing an OOXX Game with his girl friend Alice. Bob was trying to make Alice laugh and happy. So, he decided to tell jokes to Alice. Some of his jokes were funny and Alice laughed out loud. However, some of them were very boring and Alice didn't like it.
Let's mark the Game they had played as a String S. Each character of String S is either an 'O' or an 'X'. The length of String is exactly . If ='O', that means Alice liked jokes Bob had told. Otherwise, if ='X', that means Alice disliked it.
We can grade for Bob by following rules. We find each long consecutive substring of S which only contains 'O' and add the square of its length to the score. For example, S="OOOXXOOXXOOO", we can find three long consecutive substring of S which are "OOO", "OO" , "OOO". Each of their length is 3, 2, 3. So the final score we grade for Bob is .
Now, I would like to give you the possibility of each joke Alice liked. Please tell me the expected score we will grade for Bob.
Input
The first line contains an integer (), meaning the number jokes Bob had told.
The following line contains real number (), meaning the possibility of each joke Alice liked.
There will be at most six digits after the decimal point for each .
Output
Output a real number with 6 digits exactly after the decimal point indicating the expected score we will grade for Bob.
Samples
2
0.4 0.5
1.300000
3
0.000001 0.123456 0.654321
0.939338
Resources
2015 UESTC ACM Summer Training Team Selection (4)