← 返回 rippling 的题目列表Compare Two Poker Hands
类型:online_judge
Problem: Compare Two Five-Card Poker Hands
Given one five-card standard poker hand for each of two players, determine the winner.
A card consists of a rank and a suit:
Ranks: 2–9, T, J, Q, K, A, where A is highest.
Suits: C, D, H, S.
The input contains two lines, one hand per player. Cards are separated by spaces, for example: AS KD QH JC TS.
Use standard five-card poker hand categories, from strongest to weakest:
Straight Flush
Four of a Kind
Full House
Flush
Straight
Three of a Kind
Two Pair
One Pair
High Card
Comparison rules:
Compare hand categories first.
If categories are equal, compare the relevant ranks and then kickers using standard poker ordering.
An ace may be low in the straight A, 2, 3, 4, 5; that straight is treated as 5-high.
If the two hands are completely equivalent, output Tie.
Print one of: Player 1, Player 2, or Tie.
Example 1
Input:
AS KS QS JS TS
9C 9D 9H 9S 2D
Output:
Player 1
Example 2
Input:
AH AD KC KD 2S
AS AC KH KS QS
Output:
Player 2
Both hands have two pairs, Aces and Kings. Player 2 wins because its queen kicker beats Player 1's 2 kicker.
Constraints
Each player has exactly five valid, distinct cards.
No physical card appears in both hands.
Example
Input
AS KS QS JS TS
9C 9D 9H 9S 2D
Output
Player 1