luogu#P5178. 求和

求和

Background

QAQ

Problem Description

Given a sequence a1ana_1 \ldots a_n and x0x_0.

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:

i=0n+1j=0n+1f[i][j]\sum_{i=0}^{n+1}\sum_{j=0}^{n+1}f[i][j]

But this is too easy.

So mm operations are given. Each time, add pp to a[l]a[r]a[l] \ldots a[r] (0l,rn)(0\le l,r \le n). For each operation, output the answer.

In particular, if 00 is within the range lrl \ldots r, we consider that x0x_0 is also increased by pp.

Also, before reading the mm operations, you should output the answer once.

Since the answer may be too large, output the result modulo 12345678911234567891.

Input Format

The first line contains two integers n,mn, m.

The next line contains n+1n+1 integers, which are a1ana_1 \ldots a_n and x0x_0, and the last one is x0x_0.

The next mm lines each contain 33 integers l,r,pl, r, p.

Output Format

There are m+1m+1 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 2020 test points.

For the ii-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 0lrn0 \le l\le r \le n.

Didn’t expect that, right!

Translated by ChatGPT 5