#P11070. 「QMSOI R1」 三服同构
「QMSOI R1」 三服同构
Background
Not long ago, Sanguosha launched an event-exclusive general for a "triple-server isomorphic" tournament...
So what is the relationship between this problem and SP Sun Ce?
![]()
Problem Description
There are now types of playing cards: Hearts A, Hearts K, Spades A, Spades K. Little Q currently has spade cards and heart cards in hand, among which there are Spades A and Hearts A, and the opponent has cards.
Now Little Q knows that the probability that the opponent’s -th card has rank A is . Next, he will repeatedly perform the following operation until his turn ends.
- If you have at least Hearts A or Hearts K in hand, then you must discard heart-suit card uniformly at random, and duel with the opponent.
- Otherwise, you end your turn.
The duel proceeds as follows:
Starting from the opponent, the two sides alternately perform the following operation:
- If the player has at least Hearts A or Spades A in hand, then the player must discard rank-A card uniformly at random.
- Otherwise, the player takes point of damage and this duel ends.
Now you want to know, before your turn ends, how much damage the opponent is expected to take.
Input Format
The first line contains integers .
The second line contains real numbers, in order .
Output Format
Output one real number in one line, representing the expected damage.
This problem uses Special Judge. As long as the absolute error between your answer and the standard output is within , your answer will be judged correct.
2 2 1 1 2
0.2 0.8
1.670000000
Hint
Sample Explanation
We can derive that the probabilities that the opponent has A cards are , respectively.
When the opponent has A cards, no matter which red card Little Q spends each time, he can deal damage to the opponent, so the expected damage in this case is .
When the opponent has A card, suppose Little Q spends an A to duel the first time. After the opponent plays an A, Little Q will play a Spades A, and when the opponent has no A left, the opponent will take damage. Little Q’s other Hearts K can still be spent to duel and deal damage to the opponent, so the expected damage in this case is .
When the opponent has A card, suppose Little Q spends a K to duel the first time. After the opponent plays an A, Little Q has equal probability to play a Spades A or a Hearts A, and then the opponent will take damage when they have no A left. However, if Little Q plays a Hearts A, he cannot duel again, while if he plays a Spades A, the other Hearts A can still be spent to duel and deal damage to the opponent. Therefore, the expected damage in this case is .
When the opponent has A cards, if Little Q first spends an A to duel, then after the opponent plays an A, Little Q will play a Spades A. After the opponent plays another A, Little Q will take damage. Little Q’s other Hearts K can still be spent to duel and deal damage to the opponent, so the expected damage in this case is .
When the opponent has A cards, if Little Q first spends a K to duel, then both sides will each play two A cards, and then the enemy takes damage, and Little Q can no longer duel again, so the expected damage in this case is also .
So the opponent’s expected damage is .
Constraints
This problem uses bundled testing by subtasks, and the score for each subtask is as follows: | Subtask | Range | Score | | :----------: | :----------: | :----------: | | | | | | | | |
For all testdata, it holds that .
Translated by ChatGPT 5