前缀的拼接AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given an integer sequence $(A_1,\dots,A_N)$ of length $N$.
给定一个长度为 $N$ 的整数序列 $(A_1,\dots,A_N)$。AI (CI翻译)
Construct a sequence $B$ of length $\frac{N(N+1)}{2}$ by the following procedure.
按照以下过程构造一个长度为 $\frac{N(N+1)}{2}$ 的序列 $B$。AI (CI翻译)
- Initially, let
$B$be an empty sequence. - For
$i=1,2,\dots,N$in this order, append$(A_1,\dots,A_i)$to the end of$B$.
- 初始时,
$B$为空序列。 - 按照
$i=1,2,\dots,N$的顺序,将$(A_1,\dots,A_i)$追加到$B$的末尾。
You are given $Q$ queries of the following form; answer them.
给定 $Q$ 个如下形式的询问,请回答它们。AI (CI翻译)
Query: You are given $L$ and $R$. Find $B_L+B_{L+1}+\dots+B_R$.
询问:给定 $L$ 和 $R$,求 $B_L+B_{L+1}+\dots+B_R$。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \leq N \leq 10^5$$1 \leq Q \leq 10^5$$-10^8 \leq A_i \leq 10^8$- For each query,
$1\leq L\leq R \leq \frac{N(N+1)}{2}$. - All input values are integers.
$1 \leq N \leq 10^5$$1 \leq Q \leq 10^5$$-10^8 \leq A_i \leq 10^8$- 对于每个询问,
$1\leq L\leq R \leq \frac{N(N+1)}{2}$。 - 输入的所有数值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入给出,格式如下:AI (CI翻译)
N Q
A_1 A_2 \dots A_N
\mathrm{query}_1
\mathrm{query}_2
\vdots
\mathrm{query}_Q
N Q
A_1 A_2 \dots A_N
\mathrm{query}_1
\mathrm{query}_2
\vdots
\mathrm{query}_QAI (CI翻译)
Here, $\mathrm{query}_i$ represents the $i$-th query and is given in the following format:
这里,$\mathrm{query}_i$ 表示第 $i$ 个询问,格式如下:AI (CI翻译)
L R
L RAI (CI翻译)
Output
输出格式
AI (CI翻译)Print $Q$ lines.
The $i$-th line should contain the answer to the $i$-th query.
输出 $Q$ 行。
第 $i$ 行应包含第 $i$ 个询问的答案。AI (CI翻译)
样例
4 3
1 10 100 1000
3 6
1 10
8 8
121
1234
10
7 1
100000000 100000000 100000000 100000000 100000000 100000000 100000000
1 28
2800000000
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。