QOJ.ac

QOJ

Time Limit: 5.0 s Memory Limit: 2048 MB Total points: 100

#16084. 视频扑克

Statistics

视频扑克(Videopoker)是目前极受欢迎的扑克游戏在老虎机上的变种。它是换牌扑克(draw poker)的一种变体。在这款游戏中,玩家会获得一手从标准 52 张牌组中随机抽取的五张牌。玩家可以从这手牌中弃置任意数量的牌(介于 $0$ 到 $5$ 张之间,含边界),并从牌组剩余的牌中随机抽取新牌进行替换。之后,系统会对这手牌进行评估,并根据赔率表给予玩家奖励。一个常见的赔率表如下:

牌型 赔率
一对 (one pair) 1
两对 (two pair) 2
三条 (three of a kind) 3
顺子 (straight) 4
同花 (flush) 5
葫芦 (full house) 10
四条 (four of a kind) 25
同花顺 (straight flush) 100
皇家同花顺 (royal flush) 250

一旦知道了赔率表,你就可以针对给定的一手牌,确定应该更换哪些牌,以最大化你的期望收益。我们希望在给定一手初始牌的情况下,计算出这个最大期望收益。

输入格式

第一行包含一个正整数:测试用例的数量,最多为 $100$。

对于每个测试用例:

  • 第一行包含九个整数 $x_i$($0 \le x_i \le 1000$),描述赔率表。这些数字按升序排列,依次描述一对、两对、三条、顺子、同花、葫芦、四条、同花顺以及皇家同花顺的赔率。
  • 第二行包含一个整数 $n$($1 \le n \le 10$):接下来的初始手牌数量。
  • 接下来 $n$ 行,每行描述一手初始手牌。一手牌由五个空格分隔的标记组成,格式为 Xs,其中 X 表示点数(2...9TJQKA)且 s 表示花色(cdhs)。

输出格式

对于每个测试用例:

  • 对每手初始手牌输出一行,包含一个浮点数,表示该手牌的最大期望收益。这些数字的绝对或相对误差必须小于 $10^{-6}$。

样例

输入样例 1

1
1 2 3 4 5 10 25 100 250
5
Ah Ac Ad As 2s
Ks Qs Js Ts 2h
Ks Qs 2d 2h 3s
2d 4h 5d 3c 9c
2h 3h 6d 8h Tc

输出样例 1

25.000000
8.9574468
1.5467160
0.9361702
0.6608135

说明

扑克牌型说明

对于不熟悉扑克规则的读者,以下是各种扑克牌型的说明:

  • 一对 (one pair):由两张点数相同的牌和三张无法配对的牌组成,例如 Ah As Tc 8h 2c
  • 两对 (two pair):由两张点数相同的牌、另外两张点数相同的牌以及一张无法配对的牌组成,例如 Ah As Th Ts 3c
  • 三条 (three of a kind):由三张点数相同的牌和两张无法配对的牌组成,例如 Kc Kh Ks 6c 5s
  • 顺子 (straight):由五张点数连续且花色不完全相同的牌组成,例如 Jd Ts 9c 8d 7h。其中 A 既可以作为最小的牌,也可以作为最大的牌,因此可以组成 A 到 5(A-2-3-4-5)以及 10 到 A(T-J-Q-K-A)的顺子;
  • 同花 (flush):由五张花色相同但点数不连续的牌组成,例如 Ks Qs 8s 5s 3s
  • 葫芦 (full house):由三张点数相同的牌和两张另外一种点数相同的牌组成,例如 Js Jh Jc 4s 4c
  • 四条 (four of a kind):由四张点数相同的牌和一张无法配对的牌组成,例如 7h 7c 7s 7d 5c
  • 同花顺 (straight flush):由五张既成顺子又成同花的牌组成,且不是皇家同花顺,例如 7h 6h 5h 4h 3h
  • 皇家同花顺 (royal flush):由从 10 到 A 的同花顺组成,例如 As Ks Qs Js Ts

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.