当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3571:Game

Special Judge 特殊评判
题目描述

A group of contestants sits at the round table and plays the following game to relieve anxiety before the start of NEERC 2007. The game is played with a single token that is given to one person at the beginning of the game. This person passes the token to the adjacent person on the left-hand side or to the adjacent person on the right-hand side with a certain probability. A person who receives the token does the same with his own probability and so on. The game ends when each person has received the token at least once. The last person who has received the token wins.

The problem is to find the probability of winning for the given person. The probability of passing the token to the left or to the right is individual for each person and is known in advance before the beginning of the game.

Contestants are numbered from 1 to n so that the person number 2 sits to the right of 1, the person number 3 sits to the right of 2, and so on. The person number 1 sits to the right of n. The game starts with the person whose number is specified in the input file and your task is to find the probability of winning for the person number n.

Picture shows 7 contestants at the table with the token given to the person number 3.

输入解释

The first line of the input file contains two integer numbers n and k (2 ≤ n ≤ 50, 1 ≤ k < n). n denotes the total number of contestants, k denotes the number of the person who has the token at the beginning of the game.

The second line of the input file contains n − 1 numbers that denote the probabilities pi (0.01 ≤ pi ≤ 0.99) of passing the token to the right for the persons numbered from 1 to n − 1. The probability of passing the token to the left for the person number i is 1 − pi. The probabilities are given with at most 2 digits after decimal point.

输出解释

Write to the output file a single number that denotes the probability of winning for the person number n with a precision of at least 6 digits after decimal point.

输入样例
#17 3
0.5 0.5 0.5 0.5 0.5 0.5
#23 1
0.3 0.6
#324 12
0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.5 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
输出样例
#10.1666666667
#20.3000000000
#30.9800000000
提示

Note: all probabilities in the third example are on the same line in the actual input file.


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3571

最后修改于 2020-10-29T07:04:53+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000 65536