Imagine you have \(N\) boxes labeled with unique stickers indicating what's inside. Now, You decide to be mischievous and randomly shuffle the stickers on these boxes. The challenge is to figure out the probability of exactly \(i\) boxes ending up with the correct stickers modulo \(1000000007\) after this playful (random) shuffle for each \(i\) from \(0\) to \(N\).
Note: It can be proved that the sought probability is always a rational number. Additionally, the constraints of this problem guarantee that if the sought probability is represented as an irreducible fraction \(A/B\), then \(B\) is not divisible by \(1000000007\). Here, there is a unique integer \(C\) such that \(B×C≡A\) (mod \(1000000007\)). Report this \(C \ (0 \leq C \lt 10^9 + 7)\) for every probability value.
Input format
- The first line contains a single integer \(T\), which denotes the number of test cases.
- For each test case:
- A line contains a single integer \(N\) denoting the number of boxes.
Output format
For each test case, print \(N+1\) integers in a new line, where the \(i^{th}\) integer is the probability of exactly \((i-1)\) boxes ending up with the correct stickers modulo \(1000000007 \) after the playful (random) shuffle.
Constraints
1 4
375000003 333333336 250000002 0 41666667
For test case \(1\):
- N = 4
In a scenario with N=4, there are four distinct boxes, each with its unique sticker. The task is to determine the probability under modulo \(1000000007\), of exactly \(i\) boxes ending up with the correct stickers after the playful (random) shuffle for each \(i\) from \(0\) to \(N\). The total number of such random arrangements of stickers is \(24\). The probabilities are calculated as follows:
- The Probability of no box having the correct sticker: \(9/24 ≡ 375000003 \) (mod \(1000000007\)).
- The probability of exactly one box having the correct sticker: \(8/24 ≡ 333333336 \) (mod \(1000000007\)).
- The probability of exactly two boxes having the correct stickers: \(6/24 ≡ 250000002 \) (mod \(1000000007\)).
- The probability of exactly three boxes having the correct stickers: \(0/24 ≡ 0\) (mod \(1000000007\)).
- The probability of all four boxes having the correct stickers: \(1/24 ≡ 41666667\) (mod \(1000000007\)).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor