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

建议使用的浏览器:

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

5013:City Tour

Special Judge 特殊评判
题目描述
There are m visitors coming to visit country A, and they plan to visit all n cities in the country one after another. The cities are numbered from 1 to n by the order they are visited. The visitors start their tour at city 1. Each day, for each visitor i, he has pi probability to go to next city(which means city number increases by 1), and 1 - pi probability to fall in love with current city and stay there till the end of tour. If a visitor reach city n, he will not move any more.

When visitor i reach city j, he get Hij units of happiness.For j > 1, suppose city j is visited by cj(cj>0) visitors and city j - 1 is visited by cj - 1(cj - 1 > 0) visitors, then each of cj city j's visitors will get extra units of happiness.

Let htot denote the total happiness of all visitors at the end of tour. Now you need to calculate the expectation of htot.
输入解释
There are multiple test cases. Please process till EOF.

For each case, the first line contains two integers m and n (1 ≤ m ≤ 16,1 ≤ n ≤ 16) , indicating the number of visitors and the number of cities respectively.

The second line contains m real numbers pi(0 ≤ pi ≤ 1)—the probability for the ith visitor to move to next city each day. The probabilities are given with at most 6 digits after decimal point.

Then there are m lines follow, each line contains n integers. The j-th integer of ith line denotes hij (1 ≤ hij ≤ 100).
输出解释
For each test case, print a single real number in a line, represents the expectation of htot. The answer will be considered valid if it differs from the correct one by at most 10-5.
输入样例
3 1
0.1 0.2 0.3
10
20
30

3 3
0.5 0.5 0.5
1 1 1
1 1 1
1 1 1

4 4
0.1 0.4 0.2 0.3
7 2 18 10
2 6 9 5 
4 4 19 17
7 3 13 17
输出样例
60.0000000
6.84375000
34.230645587
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5013

最后修改于 2020-10-25T23:18:57+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)