#P10106. [GDKOI2023 提高组] 马戏团里你最忙
[GDKOI2023 提高组] 马戏团里你最忙
Problem Description
You are performing a show in a circus.
There is a number with initial value . Perform operations. In the -th operation, pick a number uniformly at random from . With probability , ; with probability , .
The weight of one plan is . For each , compute, among all plans with , the sum of (weight probability), taken modulo .
Input Format
The first line contains four integers . Here is the value of modulo .
The second line contains integers. The -th integer denotes .
Output Format
Output one line with integers separated by spaces. The -th integer denotes, among all plans with , the sum of (weight probability), taken modulo .
2 499122177 2 1
1 1 1 1
374341633 374341633 873463809 374341633
2 332748118 10 0
1 2 4 8
178690412 406663623 594339846 223292982
Hint
For of the testdata, .
For of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , , , .
Translated by ChatGPT 5