QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#12907. 大数获胜

统计

George 和 Gordon 正在玩一个名为“大数胜出”的游戏。

游戏规则如下:每位玩家都有一个包含 $d$ 个格子的行。初始时,所有格子都是空的。本题考虑该游戏的两种变体。

在第一种变体中,玩家轮流行动,George 先手。每次行动时,玩家掷一颗特殊的骰子,以相等的概率生成一个 $0$ 到 $b-1$ 之间的随机数字。之后,玩家将该数字放入自己行中的一个空位。

在每位玩家各进行了 $d$ 次行动后,游戏结束。获胜者是其行中组成的 $b$ 进制数较大的一方。如果两位玩家的数字相同,则为平局。

第二种变体与第一种基本相同,但 George 先完成他的 $d$ 次行动,然后 Gordon 再完成他的 $d$ 次行动。

给定 $d$ 和 $b$,求 George 在第一种和第二种变体中,通过选择正确的策略(无论 Gordon 如何行动),所能达到的最大获胜概率。

输入格式

输入文件包含多个测试用例。

每个测试用例包含一行,包含两个整数 $d$ 和 $b$ ($1 \le d \le 10, 2 \le b \le 10, (b + 1)^d \le 3000$)。

输入以一行 $d = b = 0$ 结束。

输出格式

对于每个测试用例,在一行中输出两个数字:George 在第一种和第二种变体中获胜的概率。你的答案精度需达到 $10^{-6}$。

样例

输入 1

1 2
2 2
0 0

输出 1

0.25 0.25
0.3125 0.3125

说明

在样例测试中,对于两种变体,每位玩家都必须采用以下策略:如果得到 $1$,将其放入行中最左侧的空位(对应最高位);如果得到 $0$,将其放入行中最右侧的空位。如果只有一个格子,George 只有在自己得到 $1$ 且 Gordon 得到 $0$ 时获胜,这种情况的概率为 $1/4$。如果有两个格子,在 $16$ 种可能的结果中,有 $5$ 种对 George 有利:$11$ 对 $10$、$01$ 或 $00$;$10$ 对 $00$;以及 $01$ 对 $00$。

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.