P5178 Sum

Background

QAQ

Description

Given a sequence $a_1 \ldots a_n$ and $x_0$. It satisfies: $$f[i][j]=\begin{cases} a_i & j=0,i

Input Format

The first line contains two integers $n, m$. The next line contains $n+1$ integers, which are $a_1 \ldots a_n$ and $x_0$, and the last one is $x_0$. The next $m$ lines each contain $3$ integers $l, r, p$.

Output Format

There are $m+1$ lines in total. Each line contains one integer, the answer.

Explanation/Hint

There are $20$ test points. For the $i$-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 $0 \le l\le r \le n$. ~~Didn’t expect that, right!~~ Translated by ChatGPT 5