atcoder#ABC243F. [ABC243F] Lottery
[ABC243F] Lottery
Score : points
Problem Statement
Takahashi is participating in a lottery.
Each time he takes a draw, he gets one of the prizes available. Prize is awarded with probability . The results of the draws are independent of each other.
What is the probability that he gets exactly different prizes from draws? Find it modulo .
Note
To print a rational number, start by representing it as a fraction . Here, and should be integers, and should not be divisible by (under the Constraints of this problem, such a representation is always possible). Then, print the only integer between and (inclusive) such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 1 2
2
1
221832079
Each draw awards Prize with probability and Prize with probability .
He gets Prize at both of the two draws with probability , and Prize at both draws with probability , so the sought probability is .
The modulo representation of this value, according to Note, is .
3 3 2
1
1
1
0
It is impossible to get three different prizes from two draws, so the sought probability is .
3 3 10
499122176
499122175
1
335346748
10 8 15
1
1
1
1
1
1
1
1
1
1
755239064