Harsh Comments
Time limit1sMemory limit1024 MB
Comments are deleted one at a time with probability proportional to downvotes; find the expected number of deletions until all of the first N comments are gone.
- Level
Medium7 of 10
- Topics
- Probability, Combinatorics, Math, Dynamic programming
- Solved
- No attempts yet
Problem
A blog has harsh comments. You wrote of them, and the -th of your comments has downvotes. The -th of the other comments has downvotes.
Mike will delete the comments one by one by repeating the following operation:
- Choose a comment at random and delete it. More precisely, let be the downvote counts of the remaining comments. He chooses the -th of them with probability and deletes it.
The choices in the operations are independent.
Find the expected number of operations Mike performs until he has deleted all of your comments. The answer is a rational number, so print it modulo as usual. It can be proved that this representation is always possible under the constraints of this problem.
Input
The first line contains the integers and ().
The second line contains the integers ().
The third line contains the integers (, ).
Output
Print the answer.