#P16029. [CSPro 23] 收集卡牌
[CSPro 23] 收集卡牌
Background
Luogu’s testdata is only for community communication and is not official testdata. Official judging link: https://www.cspro.org/.
Problem Description
Xiaolin is playing a gacha game. There are different types of cards, numbered from to . Each draw gives her a type card with probability . If she has already obtained this card before, it will be converted into a coin. She can use coins to exchange for one card that she has not obtained yet.
Xiaolin will keep drawing until she has collected all types of cards. Find the expected number of draws. If the absolute error between your answer and the standard answer is at most , it will be considered correct.
Hint: Smart Xiaolin will keep the coins, and when exchanging can obtain all remaining cards, she will exchange them all at once and stop drawing.
Input Format
Read from standard input.
There are two lines. The first line contains two positive integers separated by spaces. The second line gives , separated by spaces.
Output Format
Write to standard output.
Output one line with a real number, the expected number of draws.
2 2
0.4 0.6
2.52
4 3
0.006 0.1 0.2 0.694
7.3229920752
Hint
Sample 1 Explanation
There are types of cards. Let them be A and B, with probabilities and . coins can be exchanged for one card. The possible cases are:
- The first draw gets A, the second draw gets B, then it ends. Probability , number of draws .
- The first draw gets A, the second draw gets A, the third draw gets B, then it ends. Probability , number of draws .
- The first draw gets A, the second draw gets A, the third draw gets A, exchange coins for B, then it ends. Probability , number of draws .
- The first draw gets B, the second draw gets A, then it ends. Probability , number of draws .
- The first draw gets B, the second draw gets B, the third draw gets A, then it ends. Probability , number of draws .
- The first draw gets B, the second draw gets B, the third draw gets B, exchange coins for A, then it ends. Probability , number of draws .
So the answer is $0.24 \times 2 + 0.096 \times 3 + 0.064 \times 3 + 0.24 \times 2 + 0.144 \times 3 + 0.216 \times 3 = 2.52$.
Subtasks
For of the data, .
For another of the data, all are equal.
For of the data, , , all satisfy , and .
Constraints
Translated by ChatGPT 5