A - Luogu P2719 搞笑世界杯
This is a straightforward problem. We can solve it easily using DP.
DP State:
Let denote the probability that A and B end up with the same type of ticket when there are A-type tickets and B-type tickets remaining.
Answer:
Obviously, the final answer is .
Initialization:
When only one type of ticket remains, A and B will get the same type for sure, except for the case where only one ticket is left.
So we have: for .
State Transition:
Each ticket is sold based on a fair coin flip, so each choice has a probability of 50%. Therefore,
I won’t include the code here since the implementation is straightforward.
B - Luogu P8804 [蓝桥杯 2022 国 B] 故障
The basic application of Bayes’ formula.
The original statement is long and packed with information, which makes it hard to follow at first glance.
So the first step is to rewrite it in a more formal and structured way.
Let denote the probability that event occurs, and denote the probability that occurs given that has occurred.
- denotes the -th fault Symptom
- denotes the -th fault Cause
Since both terms come with the prefix “fault” and can be confusing, we will simply use the English words Symptom and Cause in the following discussion.
The problem provides:
- The prior probability of each Cause , namely
- The conditional probability , meaning that Symptom occurs given Cause
- A set of Symptoms that have already been observed
Our task is to compute the probability of each Cause occurring and then sort them accordingly.
Important assumptions:
- The system can have only one active Cause
- Given a Cause, all Symptoms occur independently
Based on the conditions above, this is a standard application of Bayes’ theorem.
The probability that Cause is responsible for the observed symptoms can be written as:
For clarity, we summarize the notation again:
- : the -th Cause
- : the -th Symptom
- : the set of observed Symptoms
Thus, the problem reduces to efficiently computing and .
The prior probability is already given in the input.
Since all Symptoms are independent given a Cause, we have:
Note that represents a specific combination of symptoms.
Therefore, we must consider not only that all symptoms in have occurred, but also that all symptoms not in have not occurred.
Once is known, computing becomes straightforward.
Since the system can have only one active Cause, we can treat this as a weighted sum:
With these probabilities computed, we can obtain for each Cause and sort them as required.
D - Luogu P1297 [国家集训队] 单选错位
Let’s analyze this case by case.
- Case 1 : In this case, it’s clear that the answer for question is also random. The expected value is:
- Case 2 : only of the possible answers for question fall within the range . Thus, the expected value is:
- Case 3 : the random answer for question is only within , and the probability that the correct answer for question falls within this range is . So the expected value becomes:
Combining all cases, the final answer is:
E - Luogu P1850 [NOIP 2016 提高组] 换教室
DP State: denote for a prefix of classroom , switch classroom for times, and we decide (not) to switch classroom on (record by , 1 for yes and 0 for no).
Transition:
int C1 = c[i - 1][0];int C2 = c[i - 1][1];int C3 = c[i][0];int C4 = c[i][1];
dp[i][j][0] = std::min( dp[i][j][0], std::min( dp[i - 1][j][0] + mp[C1][C3], // not change anymore dp[i - 1][j][1] // change on i-1 but i not + mp[C1][C3] * (1 - k[i - 1]) + mp[C2][C3] * k[i - 1] ));
dp[i][j][1] = std::min( dp[i][j][1], std::min( dp[i - 1][j - 1][0] // change on i but i-1 not + mp[C1][C3] * (1 - k[i]) + mp[C1][C4] * k[i], dp[i - 1][j - 1][1] // change both i-1 and i + mp[C2][C4] * k[i] * k[i - 1] + mp[C2][C3] * k[i - 1] * (1 - k[i]) + mp[C1][C4] * (1 - k[i - 1]) * k[i] + mp[C1][C3] * (1 - k[i - 1]) * (1 - k[i]) ));Answer is obviously.
F - Luogu P3750 [六省联考 2017] 分手是祝愿
DP State: denote the expect operator number when button quantity we need press decrease from to .
Transition:
This transition means have probability press right button, and have probability press wrong button. if we press wrong button, we need pay to make the button quantity we need press decrease to again, and continue using times operation.
then we need simplify the transition equation:
Now answer is obviously.
G - Luogu P2473 [SCOI2008] 奖励关
DP State: denote the expected score from round to round when, after the first rounds, the selection state of each item is .
Transition:
For all
- if satisfy the state requirement of item , we can decide to select it or not;
- or, just not select it.
Now answer is obiously.
Summarize
Above is the all problem of this topic.
Most of problem with probability or expectation will not use very further knowledge so just solve these problem like solving basic DP problem.