#abc314e. E - Roulettes
E - Roulettes
Score : points
问题描述
设有 个轮盘赌。第 个()轮盘上有 个整数 、、…、,玩一次需要支付 日元。当你玩第 个轮盘一次时,会从 到 (包含两端)之间均匀随机选择一个整数 ,然后你将获得 分。
各个轮盘上获得的分数独立于以往的结果。
高桥希望至少获得 分。他将采取行动以尽量减少他在至少获得 分之前所支付的金额。每次玩过后,他可以根据先前的结果来选择接下来要玩哪个轮盘。
求高桥在至少获得 分前预期需要支付的金额。
更正式的定义
以下是更为正式的问题陈述。对于高桥可以选择的某个轮盘策略,按照该策略,在至少获得 分之前他所支付的预期金额 定义如下:
- 对于自然数 ,令 表示根据该策略,高桥在至少获得 分或总共玩了 次轮盘之前预期支付的金额。令 。
在此问题条件下,无论高桥采用何种策略,可以证明 都是有限的。找出当他采用使 最小化的策略时, 的值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are roulette wheels. The -th wheel has integers written on it, and you can play it once by paying yen. When you play the -th wheel once, an integer between and , inclusive, is chosen uniformly at random, and you earn points.
The points you earn from the wheels are determined independently of past results.
Takahashi wants to earn at least points. Takahashi will act to minimize the amount of money he pays before he earns at least points. After each play, he can choose which wheel to play next based on the previous results.
Find the expected amount of money Takahashi will pay before he earns at least points.
More formal definition
Here is a more formal statement. For a strategy that Takahashi can adopt in choosing which wheel to play, the expected amount of money that he pays before he earns at least points with that strategy is defined as follows.
- For a natural number , let be the expected amount of money Takahashi pays before he earns at least points or plays the wheels times in total according to that strategy. Let .
Under the conditions of this problem, it can be proved that is finite no matter what strategy Takahashi adopts. Find the value of when he adopts a strategy that minimizes .
Constraints
- $0\leq S _ {i,j}\leq M\ (1\leq i\leq N,1\leq j\leq P _ i)$
- $\displaystyle\sum _ {j=1}^{P _ i}S _ {i,j}\gt0\ (1\leq i\leq N)$
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the expected amount of money Takahashi will pay until he earns at least points in a single line. Your output will be considered correct when the relative or absolute error from the true value is at most .
Sample Input 1
3 14
100 2 5 9
50 4 1 2 4 8
70 5 2 4 2 8 8
Sample Output 1
215.913355350494384765625
For instance, Takahashi can play the wheels as follows.
- Pay yen to play roulette and earn points.
- Pay yen to play roulette and earn point.
- Pay yen to play roulette and earn points. He has earned a total of points, so he quits playing.
In this case, he pays yen before earning points.
Your output will be considered correct when the relative or absolute error from the true value is at most , so outputs such as 215.9112
and 215.9155
would also be considered correct.
Sample Input 2
2 100
1 2 1 2
10 6 0 0 0 0 0 100
Sample Output 2
60
It is optimal to keep spinning roulette until you get points.
Sample Input 3
20 90
3252 9 0 4 2 7 3 2 3 2 4
2147 1 1
4033 8 0 4 1 7 5 2 5 0
3795 6 6 6 2 3 2 2
3941 7 2 4 4 7 2 0 5
2815 6 2 1 0 5 2 2
3020 2 3 6
3858 9 4 2 7 3 0 4 4 6 5
4533 10 3 6 4 0 6 4 4 2 7 7
4198 8 6 7 0 6 3 6 5 6
3739 8 2 7 1 5 1 4 4 7
2465 4 1 4 0 1
4418 9 7 6 2 4 6 1 5 0 7
5450 12 0 4 4 7 7 4 4 5 4 5 3 7
4196 9 1 6 5 5 7 2 3 6 3
4776 9 2 2 7 3 6 6 1 6 6
2286 3 3 5 6
3152 3 4 1 5
3509 7 0 6 7 0 1 0 3
2913 6 0 1 5 0 5 6
Sample Output 3
45037.072314895291126319493887599716
update @ 2024/3/10 08:58:47