#P16288. [蓝桥杯 2026 省 Python/Java A 组] 魔法骰子

    ID: 18303 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>动态规划 DP期望2026蓝桥杯省赛

[蓝桥杯 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 1,2,3,4,5,61,2,3,4,5,6 are p1,p2,p3,p4,p5,p6p_1, p_2, p_3, p_4, p_5, p_6, respectively.

Xiao Lan will roll this dice nn times in a row and record the result of each roll. Let LL be the maximum length of consecutive occurrences of the number 66 among these nn results.

Now, please help Xiao Lan compute the mathematical expectation of LL.

Note: The expectation of LL only depends on the probability p6p_6 of getting 66. The other probabilities p1,,p5p_1,\dots,p_5 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 nn, representing the number of rolls.

The second line contains 66 floating-point numbers p1,p2,p3,p4,p5,p6p_1, p_2, p_3, p_4, p_5, p_6 separated by spaces, representing the probabilities that the top face is 1,2,3,4,5,61,2,3,4,5,6, respectively.

Output Format

Output a floating-point number, representing the mathematical expectation of LL. 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 30%30\% of the testdata, 1n81 \leq n \leq 8.

For all testdata, 1n5001 \leq n \leq 500, i=16pi=1\sum_{i=1}^{6} p_i = 1, and pi[0,1]p_i \in [0, 1]. The Luogu testdata guarantees that each pip_i has at most 66 digits after the decimal point, and there will be no extreme constructions that “break precision”.

Translated by ChatGPT 5