Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
Statistical Charts
Submit Problem
Online Status
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
第一届北京大学游戏对抗邀请赛将与 ACM-ICPC 北京赛区同时举行,丰厚奖金等你来拿!
A Simple Poker Game
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 1475Accepted: 711


A software company wants to write a program to play a simple poker game. In the game, a player is given a hand, namely 5 distinct poker cards, from a deck of 52 distinct cards. A deck of 52 cards consists of 4suits of 13 cards each, coded and sequenced as A, 2, 3, 4, 5, 6, 7, 8, 9, X,J, Q, and K. The 4 suits are club (C), heart (H), spade (S), and diamond(D).

You tasks is to write a program to determine the points of a hand of 5cards using the following scoring rules:
  • Straight flush: 1000 points five cards of the same suit in sequence, such as 76543 of hearts. Note that AKQJX is treated as a valid sequence.
  • Four of a kind: 750 points four cards of the same rank accompanied by a "kicker", like 44442.
  • Full house: 500 points three cards of one rank accompanied by two of another, such as 777JJ.
  • Flush: 350 points five cards of the same suit, such as AJ942 of hearts.
  • Straight: 250 points five cards in sequence, such as 76543. Note that AKQJX is treated as a valid sequence.
  • Three of a kind: 200 points three cards of the same rank and two kickers of different ranks, such as KKK84.
  • Two pairs: 100 points two cards of one rank, two cards of another rank and a kicker of a third rank, such as KK449.
  • One pair: 50 points two cards of one rank accompanied by three kickers of different ranks, such as AAK53.
  • None of the above: O point any hand that does not qualify as one of the better hands above, such as KJ542 of mixed suits.

Note that if a hand satisfies two or more rules above, then we only apply the rule that wins the largest amount of points. For example, a "full house" consists of a "three of a kind" and a "one pair." You need to give
the score for "full house" only (i.e., 500 points), and nothing else.


The first line contains the number of hands w, w <= 100. Then the w hands are listed one by one. Note that each hand comes from a complete deck of52 cards. Each hand is listed in one line with 5 cards. Each card consists of two upper case letters. The first letter is its suit, and the second letter is its rank. There is a blank between two cards. The cards in one hand are not sorted at all.


For each hand, output its points in one line.

Sample Input

C3 D4 D5 S3 CX
CA C5 D4 D3 S2

Sample Output



[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator