QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100

#11952. 赌神

Statistiques

年轻时,我的父亲是一位资深博彩爱好者。有一天,我们在街上看到一位老人。他拿着一颗骰子,正与他人博弈。

每一轮,赌徒给老人 $k$ 元人民币并掷骰子。如果点数是 1、2 或 3,他将收回 $2k$ 元人民币,否则将一无所获。

我父亲告诉我:“通过以下策略,我可以赢光他的钱。”

“第一轮,我下注 1 元。如果输了,我下注 2 元。如果再输,我将下注 4、8、16 元,以此类推,直到我赢下一轮。然后我重新开始下注 1 元,并重复上述行为。”

“如果我的钱不够,我就押上我剩下的所有钱。”

假设骰子是均匀的。起初,我父亲有 $n$ 元,老人有 $m$ 元。当其中任何一方输光所有钱时,他们将停止博弈。现在的问题是:我父亲获胜的概率是多少?

输入格式

输入包含多组测试数据,最多 20 组。

对于每组测试数据,唯一的一行包含两个整数 $n$ 和 $m$ ($0 \le n, m \le 2000000$ 且 $1 \le \max(n, m)$),分别表示我父亲和老人初始拥有的金额。

输出格式

对于每组测试数据,输出我父亲获胜的概率,保留小数点后五位。

样例

输入格式 1

1 0

输出格式 1

1.00000

输入格式 2

3 3

输出格式 2

0.50000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.