#abc342f. F - Black Jack
F - Black Jack
Score: points
问题描述
你将与庄家进行一场游戏。该游戏使用一个 面骰子(dice),每次投掷都会以相等的概率显示出从 到 的整数,同时有两个变量 和 初始化为 。游戏按以下步骤进行:
-
你可以任意次数执行以下操作:投掷骰子并将结果加到 上。在每次投掷后,你可以选择是否继续投掷。
-
然后,只要 ,庄家会不断重复以下操作:投掷骰子并将结果加到 上。
-
若 ,你输掉游戏。否则,若满足 或 ,则你赢得游戏;若两者都不满足,则你输掉游戏。
确定当你采取最大化获胜概率的行动时,你的获胜概率是多少。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You will play a game against a dealer. The game uses a -sided die (dice) that shows an integer from to with equal probability, and two variables and initialized to . The game proceeds as follows:
-
You may perform the following operation any number of times: roll the die and add the result to . You can choose whether to continue rolling or not after each roll.
-
Then, the dealer will repeat the following operation as long as : roll the die and add the result to .
-
If , you lose. Otherwise, you win if or and lose if neither is satisfied.
Determine the probability of your winning when you act in a way that maximizes the probability of winning.
Constraints
- All inputs are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer. Your output will be considered correct if its absolute or relative error from the true value is at most .
Sample Input 1
3 2 2
Sample Output 1
0.468750000000000
It can be proved that the optimal strategy is to continue rolling as long as is not greater than .
Sample Input 2
200000 200000 200000
Sample Output 2
0.999986408692793
update @ 2024/3/10 01:37:06