#P5645. [PKUWC2018] 斗地主
[PKUWC2018] 斗地主
Description
Now three people are playing Dou Dizhu. If the Landlord achieves Spring, then the Landlord is considered the winner; otherwise, even if the Landlord plays all their cards first, it is still considered a win for the Farmers. Assume all three players act with optimal decisions.
You are given cards. Ask how many possible initial hands of the Landlord contain these cards, and no matter how the Farmers’ cards are distributed, the Landlord is guaranteed to achieve Spring.
Input Format
The first line contains an integer indicating the number of test cases.
For each test case, one line is given. The first integer is , the number of fixed cards, followed by space-separated integers describing each fixed card.
In particular, we use to represent rank A, for rank J, for rank Q, for rank K, for the small Joker, and for the big Joker. The input is guaranteed to be valid, meaning that the count of each rank will not exceed its count in a full deck.
Output Format
For each test case, output one integer, the number of Landlord hands that satisfy the condition. The answer may be very large; output it modulo .
Note: In this problem we ignore suits. If two hands have exactly the same multiset of ranks but different suits, they are considered the same.
6
20 1 2 2 3 4 5 6 7 8 8 9 10 11 11 12 13 13 13 13 15
20 1 1 2 2 3 4 5 6 7 8 9 10 11 12 12 12 12 13 13 14
20 1 2 2 3 3 4 5 6 7 7 7 7 8 9 10 10 11 12 13 15
20 1 2 3 4 4 5 6 7 8 9 10 11 11 12 13 13 13 13 14 15
3 3 3 3
4 3 3 3 3
1
0
1
1
4790
1670
Hint
Sample Explanation
For the first sample, we can see that the Farmers cannot have a Bomb or Rocket, so the Landlord can first play (clearly neither Farmer can beat it), then play , then play the big Joker, then play , and finally play .
| ID | ||
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 |
Translated by ChatGPT 5
京公网安备 11011102002149号