{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eTexas \u003cem\u003ehold \u0027em\u003c/em\u003e is one of the standard poker games, originated in Texas, United States. It is played with a standard deck of \u003cstrong\u003e52\u003c/strong\u003e cards, which has \u003cstrong\u003e4\u003c/strong\u003e \u003cem\u003esuits\u003c/em\u003e (spades, hearts, diamonds and clubs) and \u003cstrong\u003e13\u003c/strong\u003e \u003cem\u003eranks\u003c/em\u003e (\u003cstrong\u003eA\u003c/strong\u003e, \u003cstrong\u003eK\u003c/strong\u003e, \u003cstrong\u003eQ\u003c/strong\u003e, \u003cstrong\u003eJ\u003c/strong\u003e and \u003cstrong\u003e10\u003c/strong\u003e\\{\u003cstrong\u003e2\u003c/strong\u003e), without jokers.\u003c/p\u003e\n\n\u003cp\u003eWith betting aside, a game goes as described below.\u003c/p\u003e\n\n\u003cp\u003eAt the beginning each player is dealt with two cards face down. These cards are called \u003cem\u003ehole cards\u003c/em\u003e or \u003cem\u003epocket cards\u003c/em\u003e, and do not have to be revealed until the showdown. Then the dealer deals three cards face up as \u003cem\u003ecommunity cards\u003c/em\u003e, i.e. cards shared by all players. These three cards are called the flop. The flop is followed by another community card called the \u003cem\u003eturn\u003c/em\u003e then one more community card called the \u003cem\u003eriver\u003c/em\u003e.\u003c/p\u003e\n\n\u003cp\u003eAfter the river, the game goes on to the \u003cem\u003eshowdown\u003c/em\u003e. All players reveal their hole cards at this point. Then each player chooses five out of the seven cards, i.e. their two hole cards and the ve community cards, to form a \u003cem\u003ehand\u003c/em\u003e. The player forming the strongest hand wins the game. There are ten possible kinds of hands, listed from the strongest to the weakest:\u003c/p\u003e\n\n\u003cul\u003e\n\u003cp\u003e\u003cli\u003e \u003cem\u003eRoyal straight flush\u003c/em\u003e: \u003cstrong\u003eA\u003c/strong\u003e, \u003cstrong\u003eK\u003c/strong\u003e, \u003cstrong\u003eQ\u003c/strong\u003e, \u003cstrong\u003eJ\u003c/strong\u003e and \u003cstrong\u003e10\u003c/strong\u003e of the same suit. This is a special case of straight flush.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eStraight flush\u003c/em\u003e: Five cards in sequence (e.g. \u003cstrong\u003e7\u003c/strong\u003e, \u003cstrong\u003e6\u003c/strong\u003e, \u003cstrong\u003e5\u003c/strong\u003e, \u003cstrong\u003e4\u003c/strong\u003e and \u003cstrong\u003e3\u003c/strong\u003e) and of the same suit.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eFour of a kind\u003c/em\u003e: Four cards of the same rank.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eFull house\u003c/em\u003e: Three cards of the same rank, plus a pair of another rank.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eFlush\u003c/em\u003e: Five cards of the same suit, but not in sequence.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eStraight\u003c/em\u003e: Five cards in sequence, but not of the same suit.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eThree of a kind\u003c/em\u003e: Just three cards of the same rank.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eTwo pairs\u003c/em\u003e: Two cards of the same rank, and two other cards of another same rank.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eOne pair\u003c/em\u003e : Just a pair of cards (two cards) of the same rank.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eHigh card\u003c/em\u003e: Any other hand.\u003c/p\u003e\n\n\u003c/ul\u003e\n\n\u003cp\u003eFor the purpose of a sequence \u003cstrong\u003eJ\u003c/strong\u003e, \u003cstrong\u003eQ\u003c/strong\u003e and \u003cstrong\u003eK\u003c/strong\u003e are treated as \u003cstrong\u003e11\u003c/strong\u003e, \u003cstrong\u003e12\u003c/strong\u003e and \u003cstrong\u003e13\u003c/strong\u003e respectively. \u003cstrong\u003eA\u003c/strong\u003e can be seen as a rank either next above \u003cstrong\u003eK\u003c/strong\u003e or next below \u003cstrong\u003e2\u003c/strong\u003e, thus both \u003cstrong\u003eA\u003c/strong\u003e-\u003cstrong\u003eK\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e10\u003c/strong\u003e and \u003cstrong\u003e5\u003c/strong\u003e-\u003cstrong\u003e4\u003c/strong\u003e-\u003cstrong\u003e3\u003c/strong\u003e-\u003cstrong\u003e2\u003c/strong\u003e-\u003cstrong\u003eA\u003c/strong\u003e are possible (but not \u003cstrong\u003e3\u003c/strong\u003e-\u003cstrong\u003e2\u003c/strong\u003e-\u003cstrong\u003eA\u003c/strong\u003e-\u003cstrong\u003eK\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e or the likes).\u003c/p\u003e\n\n\u003cp\u003eIf more than one player has the same kind of hand, ties are broken by comparing the ranks of the cards.\u003c/p\u003e\n\n\u003cp\u003eThe basic idea is to compare first those forming sets (pairs, triples or quads) then the rest cards one by one from the highest-ranked to the lowest-ranked, until ties are broken. More specifically:\u003c/p\u003e\n\n\u003cul\u003e\n\u003cp\u003e\u003cli\u003e \u003cem\u003eRoyal straight flush\u003c/em\u003e: (ties are not broken)\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eStraight flush\u003c/em\u003e: Compare the highest-ranked card.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eFour of a kind\u003c/em\u003e: Compare the four cards, then the remaining one.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eFull house\u003c/em\u003e: Compare the three cards, then the pair.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eFlush\u003c/em\u003e: Compare all cards one by one.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eStraight\u003c/em\u003e: Compare the highest-ranked card.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eThree of a kind\u003c/em\u003e: Compare the three cards, then the remaining two.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eTwo pairs\u003c/em\u003e: Compare the higher-ranked pair, then the lower-ranked, then the last one.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eOne pair\u003c/em\u003e : Compare the pair, then the remaining three.\u003c/p\u003e\n\n\u003cp\u003e\u003cli\u003e \u003cem\u003eHigh card\u003c/em\u003e: Compare all cards one by one.\u003c/p\u003e\n\n\u003c/ul\u003e\n\n\u003cp\u003eThe order of the ranks is \u003cstrong\u003eA\u003c/strong\u003e, \u003cstrong\u003eK\u003c/strong\u003e, \u003cstrong\u003eQ\u003c/strong\u003e, \u003cstrong\u003eJ\u003c/strong\u003e, \u003cstrong\u003e10\u003c/strong\u003e, \u003cstrong\u003e9\u003c/strong\u003e, ... , \u003cstrong\u003e2\u003c/strong\u003e, from the highest to the lowest, except for \u003cstrong\u003eA\u003c/strong\u003e next to \u003cstrong\u003e2\u003c/strong\u003e in a straight regarded as lower than \u003cstrong\u003e2\u003c/strong\u003e. Note that there are exceptional cases where ties remain. Also note that the suits are not considered at all in tie-breaking.\u003c/p\u003e\n\n\u003cp\u003eHere are a few examples of comparison (note these are only intended for explanatory purpose; some combinations cannot happen in Texas Hold \u0027em):\u003c/p\u003e\n\n\u003cul\u003e\n\u003cp\u003e\u003cli\u003e \u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e6\u003c/strong\u003e-\u003cstrong\u003e3\u003c/strong\u003e and \u003cstrong\u003eK\u003c/strong\u003e-\u003cstrong\u003eK\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e.\u003c/p\u003e\n\n\u003c/ul\u003e\n\n\u003cp\u003eThe former beats the latter since three of a kind is stronger than two pairs.\u003c/p\u003e\n\n\u003cul\u003e\n\u003cp\u003e\u003cli\u003e \u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e6\u003c/strong\u003e-\u003cstrong\u003e3\u003c/strong\u003e and \u003cstrong\u003eK\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e.\u003c/p\u003e\n\n\u003c/ul\u003e\n\n\u003cp\u003eSince both are three of a kind, the triples are considered first, \u003cstrong\u003eJ\u003c/strong\u003e and \u003cstrong\u003e8\u003c/strong\u003e in this case. \u003cstrong\u003eJ\u003c/strong\u003e is higher, hence the former is a stronger hand. The remaining cards, \u003cstrong\u003e6\u003c/strong\u003e-\u003cstrong\u003e3\u003c/strong\u003e and \u003cstrong\u003eK\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e, are not considered as the tie is already broken.\u003c/p\u003e\n\n\u003cul\u003e\n\u003cp\u003e\u003cli\u003e \u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e-\u003cstrong\u003e6\u003c/strong\u003e-\u003cstrong\u003e3\u003c/strong\u003e and \u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e-\u003cstrong\u003e5\u003c/strong\u003e-\u003cstrong\u003e3\u003c/strong\u003e.\u003c/p\u003e\n\n\u003c/ul\u003e\n\n\u003cp\u003eBoth are high cards, assuming hands not of a single suit (i.e. flush). The three highest-ranked cards \u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e are the same, so the fourth highest are compared. The former is stronger since \u003cstrong\u003e6\u003c/strong\u003e is higher than \u003cstrong\u003e5\u003c/strong\u003e.\u003c/p\u003e\n\n\u003cul\u003e\n\u003cp\u003e\u003cli\u003e \u003cstrong\u003e9\u003c/strong\u003e-\u003cstrong\u003e9\u003c/strong\u003e-\u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003e7\u003c/strong\u003e-\u003cstrong\u003e2\u003c/strong\u003e and \u003cstrong\u003e9\u003c/strong\u003e-\u003cstrong\u003e9\u003c/strong\u003e-\u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e-\u003cstrong\u003e5\u003c/strong\u003e.\u003c/p\u003e\n\n\u003c/ul\u003e\n\n\u003cp\u003eBoth are one pair, with the pair of the same rank (\u003cstrong\u003e9\u003c/strong\u003e). So the remaining cards, \u003cstrong\u003eQ\u003c/strong\u003e-\u003cstrong\u003e7\u003c/strong\u003e-\u003cstrong\u003e2\u003c/strong\u003e and \u003cstrong\u003eJ\u003c/strong\u003e-\u003cstrong\u003e8\u003c/strong\u003e-\u003cstrong\u003e5\u003c/strong\u003e, are compared from the highest to the lowest, and the former wins as \u003cstrong\u003eQ\u003c/strong\u003e is higher than \u003cstrong\u003eJ\u003c/strong\u003e.\u003c/p\u003e\n\n\u003cp\u003eNow suppose you are playing a game of Texas Hold \u0027em with one opponent, and the hole cards and the op have already been dealt. You are surprisingly telepathic and able to know the cards the opponent has. Your ability is not, however, as strong as you can predict which the turn and the river will be.\u003c/p\u003e\n\n\u003cp\u003eYour task is to write a program that calculates the probability of your winning the game, assuming the turn and the river are chosen uniformly randomly from the remaining cards. You and the opponent always have to choose the hand strongest possible. Ties should be included in the calculation, i.e. should be counted as losses.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eInput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eConsists of multiple datasets, each of which has the following format:\u003c/p\u003e\n\n\u003cp\u003e\u003cstrong\u003eYourCard_1 YourCard_2\u003c/strong\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003cstrong\u003eOpponentCard_1 OpponentCard_2\u003c/strong\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003cstrong\u003eCommunityCard_1 CommunityCard_2 CommunityCard_3\u003c/strong\u003e\u003c/p\u003e\n\n\u003cp\u003eEach dataset consists of three lines. The first and second lines contain the hole cards of yours and the opponent\u0027s respectively. The third line contains the flop, i.e. the first three community cards. These cards are separated by spaces.\u003c/p\u003e\n\n\u003cp\u003eEach card is represented by two characters. The fi rst one indicates the suit: \u003cstrong\u003eS\u003c/strong\u003e (spades), \u003cstrong\u003eH\u003c/strong\u003e (hearts), \u003cstrong\u003eD\u003c/strong\u003e (diamonds) or \u003cstrong\u003eC\u003c/strong\u003e (clubs). The second one indicates the rank: \u003cstrong\u003eA\u003c/strong\u003e, \u003cstrong\u003eK\u003c/strong\u003e, \u003cstrong\u003eQ\u003c/strong\u003e, \u003cstrong\u003eJ\u003c/strong\u003e, \u003cstrong\u003eT\u003c/strong\u003e (\u003cstrong\u003e10\u003c/strong\u003e) or \u003cstrong\u003e9 \u003c/strong\u003e- \u003cstrong\u003e2\u003c/strong\u003e. The end of the input is indicated by a line with \"\u003cstrong\u003e#\u003c/strong\u003e\". This should not be processed.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eOutput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003ePrint the probability in a line. The number may contain an arbitrary number of digits after the decimal point, but should not contain an absolute error greater than \u003cstrong\u003e10^\\{-6\\\u003c/strong\u003e}.\u003c/p\u003e\n\n"}},{"title":"Example","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eSA SK\nDA CA\nSQ SJ ST\nSA HA\nD2 C3\nH4 S5 DA\nHA D9\nH6 C9\nH3 H4 H5\n#\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1.00000000000000000000\n0.34444444444444444198\n0.63030303030303025391\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}