luogu#P5178. 求和
求和
Background
QAQ
Problem Description
Given a sequence and .
It satisfies:
$$f[i][j]=\begin{cases} a_i & j=0,i<=n \\ x_0 & j=0,i=n+1 \\ f[i][j-1]+f[i-1][j-1] & 0<i,j<=n+1,j<i \\ 0 & i<=j \\ \end{cases}$$Find:
But this is too easy.
So operations are given. Each time, add to . For each operation, output the answer.
In particular, if is within the range , we consider that is also increased by .
Also, before reading the operations, you should output the answer once.
Since the answer may be too large, output the result modulo .
Input Format
The first line contains two integers .
The next line contains integers, which are and , and the last one is .
The next lines each contain integers .
Output Format
There are lines in total. Each line contains one integer, the answer.
2 2
1 2 3
1 2 3
0 1 3
22
46
64
Hint
There are test points.
For the -th test point:
$$n,m=\lfloor ln^{12}i+\pi^5\rfloor,|a,x,p|\le \lfloor ln^{19}i+i^{\pi}\rfloor$$It is guaranteed that .
Didn’t expect that, right!
Translated by ChatGPT 5