Biology
Time limit2sMemory limit512 MB
Count the possible five-card hands for each of nine poker categories, given two fixed cards from a deck with A ranks and B suits.
- Level
Medium6 of 10
- Topics
- Combinatorics, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Vera has cards. Each card has a rank, an integer between and , and a suit, an integer between and . All cards are distinct. A set of five different cards is a hand.
Every hand falls into exactly one of nine categories numbered through . If a hand satisfies the conditions of more than one category, it belongs to the lowest numbered category among them. The rules are:
- Straight flush: the hand is a straight and a flush.
- Four of a kind: four of the cards have the same rank.
- Full house: three of the cards have the same rank and the remaining two have the same rank.
- Flush: all five cards have the same suit.
- Straight: the ranks of the cards in increasing order are for some integer .
- Three of a kind: three of the cards have the same rank.
- Two pair: two cards have the same rank and two other cards have the same rank.
- One pair: two cards have the same rank.
- High card: the hand satisfies no other category.
Vera currently holds two cards with ranks , and suits , . She picks three more cards from the remaining ones and forms a hand with the two she holds. Compute the number of different hands formed this way that belong to each category.
Input
The first line contains the integers and (, ).
The second line contains the integers , , , (, , ).
Output
Print one line with nine integers separated by single spaces. The -th integer is the number of different hands that belong to category , so the counts run from straight flush to high card in increasing order of category number.
Hint
Let denote the card with rank and suit .
In the first example Vera holds and . If she picks , , , her hand has two cards of rank and two other cards of rank , so it is a two pair. The same hand also satisfies one pair, but two pair has the lower category number, so it counts as a two pair.