#P11900. 不知道
不知道
Background
Unknown, the terrifying Cat-demon, is the archenemy of “Furrmes”.
One day, she saw an elementary-school math olympiad problem online: the Josephus problem.
Problem Description
Unknown is going to commit another crime. She makes cats stand in a line. From left to right, their initial labels are . At the same time, each cat initially stands on the cell with the same number as its label.
Unknown has favorite numbers . They satisfy:
- .
- For , .
- .
Unknown will pet cats for rounds. In each round, she will pet exactly one cat. One “petting” follows these rules:
- Randomly choose a number from to .
- If there is currently a cat standing on cell , Unknown will pet that cat. Then the cat will run away from the cells and will no longer participate in any later process, and proceed to Step 3. Otherwise, go back to Step 1.
- Let all remaining cats run to new cells. If there are cats at this moment, they will line up onto cells while keeping their relative order unchanged.
However, although cats are cute, both the cats and Unknown can get tired of this. So when only one cat is left, Unknown will stop petting. Please compute, for each cat, the probability that it is not petted in the end.
Output the final answers modulo .
Input Format
The first line contains two integers and , meaning there are cats in total, and Unknown has favorite numbers.
The second line contains integers, representing through , separated by spaces.
Output Format
Output one line with integers. The -th integer is the probability that the cat with initial label is not petted, separated by spaces, taken modulo .
2 0
0 1
4 1
3
0 748683265 748683265 499122177
8 3
3 6 8
0 291154603 291154603 582309206 166374059 166374059 748683265 748683265
Hint
Sample Explanation:
In the first sample, Unknown only likes the number , so each time she will definitely pet the current first cat. Therefore, the first cat will surely be petted, and the second cat will surely not be petted.
In the second sample, from left to right, the probabilities that the four cats are not petted are .
Constraints:
This problem uses bundled testdata.
For all testdata, it is guaranteed that , and the range of is as described above.
| # | Special Property | Score |
|---|---|---|
| 0 | 10 | |
| 1 | 5 | |
| 2 | 10 | |
| 3 | 15 | |
| 4 | ||
| 5 | 20 | |
| 6 | No special restrictions | 25 |
Postscript:
Peanut: So what is Unknown’s real name?
Furrmes: I don’t know, so she is called Unknown.
Peanut: ?
Translated by ChatGPT 5