#arc177d. D - Earthquakes
D - Earthquakes
Score: points
问题陈述
AtCoder街是一条在平坦地面上由直线表示的道路。这条道路上有根高度为的电线杆。这些电线杆按照时间顺序编号为。电线杆()垂直位于坐标。每个电线杆的底部都固定在地面上。 假设电线杆足够薄。
这条街道将经历次地震。在第次地震()期间,发生以下事件:
- 如果电线杆还没有倒下,它将以的概率向左或向右倒在数轴上。
- 如果一个倒下的电线杆与另一个还没有倒下的电线杆(包括在电线杆底部的碰撞)相撞,后者也会朝同一方向倒下。这可能会触发连锁反应。
在步骤1中,电线杆倒下的方向与其他电线杆倒下的方向是独立的。
下面的图示是一个地震期间电线杆可能倒下方式的示例:
为了地震准备,对于每个,找出所有电线杆恰好在第次地震中倒下的概率。将其乘以并打印结果,模。可以证明要打印的值是整数。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
AtCoder Street is a road represented by a straight line on flat ground. There are utility poles of height standing on this road. The poles are numbered in chronological order. Pole () is vertically positioned at coordinate . The base of each pole is fixed to the ground. Assume that the poles are sufficiently thin.
The street will experience earthquakes. During the -th earthquake , the following events occur:
- If pole has not yet fallen, it falls to the left or the right on the number line, each with a probability of .
- If a falling pole collides with another pole that has not yet fallen (including collision at the base of the pole), the latter pole will also fall in the same direction. This may trigger a chain reaction.
The direction in which a pole falls during step 1 is independent of the direction in which other poles have fallen.
The following figure is an example of how poles might fall during one earthquake:
For earthquake preparedness, for each , find the probability that all poles have fallen by exactly the -th earthquake. Multiply it by and print the result modulo . It can be proved that the values to be printed are integers.
Constraints
- are all distinct.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answers for in this order, separated by spaces.
Sample Input 1
3 2
0 3 1
Sample Output 1
4 2 2
The following figure shows the possible ways the poles can fall for this sample input. The fractions in the figure indicate the probability of each state occurring.
Therefore, the probabilities that all poles have fallen by exactly the -st, -nd, -rd earthquakes are , , , respectively. Multiply these by to get for output.
Sample Input 2
4 10
10 55 20 45
Sample Output 2
0 4 4 8
The following figure shows the possible ways the poles can fall for this sample input. The fractions in the figure indicate the probability of each state occurring.
Therefore, the probabilities that all poles have fallen by exactly the -st, -nd, -rd, -th earthquakes are , , , , respectively. Multiply these by to get for output.
Sample Input 3
8 1
5 0 6 3 8 1 7 2
Sample Output 3
0 64 32 48 24 28 28 32
The probabilities that all poles have fallen by exactly the -st, -nd, -rd, -th, -th, -th, -th, -th earthquakes are , , , , , , , , respectively.
Sample Input 4
40 20
695 793 11 502 114 861 559 4 212 609 894 435 429 94 91 258 161 45 33 605 673 634 629 163 283 826 409 84 507 548 31 248 588 340 357 168 926 949 322 912
Sample Output 4
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41942627 41942627 360709869
Not all poles will have fallen by the -th earthquake. The probabilities that all poles have fallen by exactly the , , -th earthquakes are , , , respectively.