#P6026. 餐馆
餐馆
Description
The restaurant offers signature dishes, numbered .
One day, customers came to the restaurant, and they had not decided what to eat. So Xiao W gave them an idea: each person first randomly chooses a number from with equal probability, then randomly chooses a number from with equal probability. This person then orders all dishes with numbers between and (including and ).
So the customers did as Xiao W said. After all customers finished ordering, Xiao W suddenly realized: no two people ordered the same dish, so he only needs to cook at most one portion of each dish. To prove how lucky he is, he found you, who studies programming, and asks you to help compute the probability that this situation happens.
Input Format
Two integers and , as described in the statement.
Output Format
Output one integer , which is the required probability modulo .
10 1
1
2 2
250000002
Hint
Explanation of the samples:
Sample : Because there is only one customer, no matter what happens, there cannot be two people ordering the same dish. Therefore, the required probability is .
Sample : For each customer, the probability of ordering only dish is , the probability of ordering only dish is , and the probability of ordering both dishes is . For the two people to not order any common dish, one must order only dish and the other must order only dish . The probability is $\dfrac14\times\dfrac12+\dfrac12\times\dfrac14=\dfrac14$, which modulo is .
Hint: If you do not know how to take a rational number modulo, please see P2613.
Constraints:
For of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For all testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号