#P8478. 「GLR-R3」清明
「GLR-R3」清明
Background
" , "
"You keep saying this is not my true strength, so why can't one accidental wrong note ruin my fate?!"
Tianyi did not notice that the person she was crying out to in her heart, like her, was holding an umbrella, only a dozen steps behind her.
Qingming "In the abyss called weakness, what have you actually seen?"
Problem Description
Raindrops hit the window ledges, falling down step by step.
There are window ledges in total, numbered from top to bottom. The highest ledge is numbered , and the lowest ledge is numbered . Suppose that at some instant, there are units of rainwater on ledge . Due to some magical physical reasons, the rainwater on ledge will, in the "next instant", drip to ledges , or it may stay on ledge . For each possible destination, the amount of water (in units of volume) must be a non-negative integer, and the total must be .
Let be the amount of rainwater on ledge in the "next instant". Then the magic value of the rainwater at that time is defined as . Now, the sad person wants to know: among all essentially different "next instants", what is the sum of the magic values modulo the prime ?
Two "next instants" are essentially different if and only if there exist two ledges with indices such that the amount of water dripping from ledge to ledge is different.
Input Format
The first line contains two positive integers , representing the number of window ledges and the constant that limits the dripping distance.
The second line contains non-negative integers , where is the volume of rainwater on ledge at the current instant.
Output Format
Output one integer in one line, representing the sum of the magic values over all essentially different "next instants", taken modulo .
3 0
2 2 2
8
3 1
2 2 2
30
5 3
2 3 4 4 3
275200
Hint
Sample #1 Explanation.
It is easy to see that there is only one essentially different "next instant": no ledge drips any water to other ledges.
So finally , and the value is .
Sample #2 Explanation.
Let denote the volume of rain dripping from ledge to ledge . Clearly, .
Enumerate all valid dripping situations:
- , value ;
- , value ;
- , value ;
- , value ;
- , value ;
- , value ;
- . In this case, must hold, and the values of the three plans in this case are all .
Therefore, the total sum of values over all essentially different "next instants" is .
Constraints
This problem uses Subtask-based scoring.
For of the testdata, , and .
For different subtasks, the constraints are as follows:
| Subtask ID | Score | |||
|---|---|---|---|---|
Translated by ChatGPT 5