[关闭]
@l1ll5 2020-07-11T08:49:26.000000Z 字数 3310 阅读 732

Poker

——by l1ll5

2 seconds 、256 megabytes


题目背景

Fujiwara no Mokou and Houraisan Kaguya do not want to play ping-pong today, they have decided to play Texas hold'em.

Now let me intruduce one of the simplified rule of Texas hold'em.

For a deck of Poker Cards,there are 52 cards.And each card have two states: pips and suits.

Pips are used to compare two cards, there 13 kinds of pips(A,K,Q,J,10,9,8,7,6,5,4,3,2).
And there are 4 kinds of suits:diamonds (♦), clubs (♣), hearts (♥) and spades (♠)。

Which means, there aren't two cards with same pips and suits in a match.

For one match of two players, there are 9 differents cards.
Each player have two pocket cards at the beginning of the match.And only himself/herself knows what they are.

Then the Dealer(who host the game) will deal a flop : show 3 face-up community cards.And after the betting round, deal the turn and the river : another 2 face-up community cards.

When the community cards are all shown, the players show there pocket cards and choose 5 cards in the 7 cards(2 pocket cards + 5 community cards)to construct the Hand.

After that, compare your Hand with another player,the player who has bigger Hand values will win the game.

For all the possible types of Hand, the following table shows the possible Hand values in increasing order.

  1. Royal flush:Straight flush from Ten to Ace.(A K Q J 10)
  2. Straight flush:Straight of the same suit.
  3. Four of a kind:Four cards of the same value.(A A A A 10)
  4. Full house:Combination of three of a kind and a pair.(3 3 3 10 10)
  5. Flush:5 cards of the same suit.
  6. Straight:Sequence of 5 cards in increasing value.(2 3 4 5 6)
  7. Three of a kind:Three cards with the same value.(4 4 4 3 7)
  8. Two pairs:Two times two cards with the same value.(4 4 5 5 6)
  9. Pair:Two cards with the same value.
  10. Highcard:Simple value of the card. Lowest: 2 - Highest: Ace

If a Hand match many kinds of Hand values above, now we consider it as the bigger one.

The Hand with bigger values is absolutely bigger,for the Hands with the same value, we compare them with the following rules.

  1. Royal flush:Draw.
  2. Straight flush:Compare with the bigger card.
  3. Four of a kind:First compare the four cards of the same value.Then the other one.
  4. Full house:First compare the three cards of the same value.Then the pair.
  5. Flush:Sort the cards by their pips and compare them one-by-one.
  6. Straight:Compare with the bigger card.
  7. Three of a kind:First compare the three cards of the same value.The the other two in the pip's order.
  8. Two pairs:First the bigger pair, then the smaller pair, and last the other one card.
  9. Pair:First the pair, then the other cards in the pip's order.
  10. Highcard:Sort the cards by their pips and compare them one-by-one.

And there are two points need to pay attention to.

  1. The suit of a card do not influence the compare of two Hands of the same Hand value.
  2. Ace(A) is also a part of Straight of A K Q J 10 and the part of 1 2 3 4 5.When it become 1 but not A, it's smaller then 2.Or it's the biggest card.

Some cases to get better understanding.

A A A 3 3 Q Q Q 3 3
7 8 9 10 J K K K 4 3
9 9 4 7 10 9 9 4 7 8
5 6 8 9 K 5 6 9 J Q
A K Q J 10 1 2 3 4 5

Fujiwara no Mokou have already know the two pocket cards of herself and Houraisan Kaguya , and the first 3 community cards are already shown.
If the following 2 community cards are chosen randomly , Fujiwara no Mokou wants to know the possibility of she can win the match.

Note:Draw isn't win.


输入格式

The first line contains a positive integer () , indicates there are T test cases.

For one card, there are 2 characters to describe it.
The first character: one of S H D C, indicates the suit.
The second: one of A K Q J T 1-9,T is 10, indicates the pips.

For one test case, contains 3 lines.
The first line:the two pocket cards of Fujiwara no Mokou.
The second line:the two pocket cards of Houraisan Kaguya.
The third line:the three community cards already shown.


输出格式

For each test case, output a number in the range of 0 to 1, indicates the answer.

If the difference between your answer and the std's answer is lower than , your answer is correct.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注