#abc342f. F - Black Jack

F - Black Jack

Score: 550550 points

问题描述

你将与庄家进行一场游戏。该游戏使用一个 DD 面骰子(dice),每次投掷都会以相等的概率显示出从 11DD 的整数,同时有两个变量 xxyy 初始化为 00。游戏按以下步骤进行:

  • 你可以任意次数执行以下操作:投掷骰子并将结果加到 xx 上。在每次投掷后,你可以选择是否继续投掷。

  • 然后,只要 y<Ly < L,庄家会不断重复以下操作:投掷骰子并将结果加到 yy 上。

  • x>Nx > N,你输掉游戏。否则,若满足 y>Ny > Nx>yx > y,则你赢得游戏;若两者都不满足,则你输掉游戏。

确定当你采取最大化获胜概率的行动时,你的获胜概率是多少。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You will play a game against a dealer. The game uses a DD-sided die (dice) that shows an integer from 11 to DD with equal probability, and two variables xx and yy initialized to 00. The game proceeds as follows:

  • You may perform the following operation any number of times: roll the die and add the result to xx. You can choose whether to continue rolling or not after each roll.

  • Then, the dealer will repeat the following operation as long as y<Ly < L: roll the die and add the result to yy.

  • If x>Nx > N, you lose. Otherwise, you win if y>Ny > N or x>yx > y 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.
  • 1LN2×1051 \leq L \leq N \leq 2 \times 10^5
  • 1DN1 \leq D \leq N

Input

The input is given from Standard Input in the following format:

NN LL DD

Output

Print the answer. Your output will be considered correct if its absolute or relative error from the true value is at most 10610^{-6}.

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 xx is not greater than 22.

Sample Input 2

200000 200000 200000

Sample Output 2

0.999986408692793

update @ 2024/3/10 01:37:06