#abc313f. F - Flip Machines
F - Flip Machines
Score : points
问题描述
设有 张卡片,编号为 到 。每张卡片的一面都写有一个整数;第 张卡片正面写有整数 ,背面写有整数 。最初,所有卡片都是正面朝上。
共有 台机器,编号从 到 。第 台机器上有两个(不一定互异)整数 和 ,它们都在 到 的范围内。如果启动第 台机器,它将以 的概率翻转卡片 ,并以剩下的 的概率翻转卡片 。每次启动机器时,这个概率都是独立的。
Snuke 将执行以下操作:
- 选择一个包含从 到 整数的集合 。
- 按升序遍历集合 中的每个元素,并依次启动对应编号的机器。
在 Snuke 对 的所有可能选择中,找出该过程结束后,卡片正面朝上的整数之和的最大期望值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are cards numbered through . Each face of a card has an integer written on it; card has on its front and on its back. Initially, all cards are face up.
There are machines numbered through . Machine has two (not necessarily distinct) integers and between and . If you power up machine , it flips card with the probability of , and flips card with the remaining probability of . This probability is independent for each power-up.
Snuke will perform the following procedure.
- Choose a set consisting of integers from through .
- For each element in in ascending order, power up the machine with that number.
Among Snuke's possible choices of , find the maximum expected value of the sum of the integers written on the face-up sides of the cards after the procedure.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer. Your output is considered correct if the absolute or relative difference from the true value is at most .
Sample Input 1
3 1
3 10
10 6
5 2
1 2
Sample Output 1
19.500000
If is chosen to be an empty set, no machine is powered up, so the expected sum of the integers written on the face-up sides of the cards after the procedure is .
If is chosen to be , machine is powered up.
- If card is flipped, the expected sum of the integers written on the face-up sides of the cards after the procedure is .
- If card is flipped, the expected sum of the integers written on the face-up sides of the cards after the procedure is .
Thus, the expected value is .
Therefore, the maximum expected value of the sum of the integers written on the face-up sides of the cards after the procedure is .
Sample Input 2
1 3
5 100
1 1
1 1
1 1
Sample Output 2
100.000000
Different machines may have the same .
Sample Input 3
8 10
6918 9211
16 1868
3857 8537
3340 8506
6263 7940
1449 4593
5902 1932
310 6991
4 4
8 6
3 5
1 1
4 2
5 6
7 5
3 3
1 5
3 1
Sample Output 3
45945.000000
update @ 2024/3/10 08:56:27