#P16288. [蓝桥杯 2026 省 Python/Java A 组] 魔法骰子
[蓝桥杯 2026 省 Python/Java A 组] 魔法骰子
Problem Description
Xiao Lan wants to use a 6-sided magic dice to test his luck. When rolling this dice, the probabilities that the top face is are , respectively.
Xiao Lan will roll this dice times in a row and record the result of each roll. Let be the maximum length of consecutive occurrences of the number among these results.
Now, please help Xiao Lan compute the mathematical expectation of .
Note: The expectation of only depends on the probability of getting . The other probabilities are only used to ensure the probability distribution of the dice is complete.
Input Format
The input has two lines.
The first line contains a positive integer , representing the number of rolls.
The second line contains floating-point numbers separated by spaces, representing the probabilities that the top face is , respectively.
Output Format
Output a floating-point number, representing the mathematical expectation of . Round the result to two decimal places.
10
0.1 0.2 0.2 0.1 0.2 0.2
1.23
Hint
Constraints and Notes
For of the testdata, .
For all testdata, , , and . The Luogu testdata guarantees that each has at most digits after the decimal point, and there will be no extreme constructions that “break precision”.
Translated by ChatGPT 5