Twinkle Twinkle 2
Time limit1sMemory limit1024 MB
Each light has an on-probability; an added light between neighbors turns on exactly when one neighbor is on. Find the expected total number of lit lights.
- Level
Easy3 of 10
- Topics
- Probability, Math, Implementation, Array
- Solved
- No attempts yet
Problem
Last winter, Suhyeon used a strip of lights to decorate a Christmas tree. Gukryeol stole the leftover strip and wants to use it to decorate his room.
The strip has lights arranged in a straight line. Each light has its own probability of turning on when power is applied.
Gukryeol, an electronics expert, rewired the circuit so that one light failing does not affect the others. He still did not find it twinkly enough, so he added one extra light between every pair of adjacent lights on the strip. An extra light turns on only when exactly one of the two lights next to it turns on.
Find the expected number of lights on the strip that turn on.
Input
The input is given as follows.
- is the number of lights. ()
- is the probability that the -th light turns on, given with exactly two digits after the decimal point. ()
Output
Print the expected number of lights that turn on.
The absolute or relative error from the correct answer must be at most .