#P5488. 差分与前缀和
差分与前缀和
Problem Description
Given a sequence of length , find its -th order difference or prefix sum.
Each term of the result needs to be taken modulo .
Input Format
The first line contains three integers . If , compute the prefix sum; if , compute the difference.
The second line contains integers representing the sequence .
Output Format
Output one line with integers, representing the -th order difference or prefix sum of .
8 3 0
1 9 2 6 0 8 1 7
1 12 35 76 135 220 332 478
8 3 1
1 9 2 6 0 8 1 7
1 6 1004535787 26 1004535788 24 1004535780 28
Hint
Constraints
$1 \le k \le 10^{2333}, k \not \equiv 0 \pmod{1004535809}$
Translated by ChatGPT 5