A higher resolution is required to access the IDE
- 4
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
You have aT indicates the type of the card:
•
•
•
•
•
C represents the mana cost of the card. It is an integer from
P indicates the color of the card:
•
•
•
•
•
For example:
•
•
•
You will draw a
Each pattern is a 3-character string where each character may be a specific value or
For example:
•
•
•
== Example ==
Input:
7
C1R 10
C2B 5
C3G 8
I2U 12
S4W 5
L0G 15
L0B 5
2
C1x
LxB
Output:
0.3334
== Explanation ==
There are
There are
The probability that a 7-card hand includes at least one card from each of those patterns is approximately 0.3334.
Input
Line 1: An integer C — the number of distinct categories in the deck.
Next C lines: Category Count — a 3-letter category code and the number of cards in that category separated by a space.
Next line: An integer Q — the number of patterns.
Next Q lines: Pattern — a 3-character string representing a pattern to match, and may contain any number ofx s as wildcards.
Next C lines: Category Count — a 3-letter category code and the number of cards in that category separated by a space.
Next line: An integer Q — the number of patterns.
Next Q lines: Pattern — a 3-character string representing a pattern to match, and may contain any number of
Output
Output a single line: the probability (a decimal between 0 and 1) that a random 7-card hand includes at least one card matching each of the given patterns, rounded to four decimal places .
Constraints
1 ≤ C ≤ 60
The sum of all Count is exactly 60.
1 ≤ Q ≤ 8
The sum of all Count is exactly 60.
1 ≤ Q ≤ 8
Example
Input
2 L0R 26 C1R 34 1 Lxx
Output
0.9861
A higher resolution is required to access the IDE