AtCoder Grand Contest 023
翻译中…
Problem Statement
翻译中…
We have an integer sequence $A$, whose length is $N$.
翻译中…
Find the number of the non-empty contiguous subsequences of $A$ whose sums are $0$. Note that we are counting the ways to take out subsequences. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$$-10^9 \leq A_i \leq 10^9$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 ... A_N
翻译中…
Output
翻译中…
Find the number of the non-empty contiguous subsequences of $A$ whose sum is $0$.
翻译中…
样例
Input #1
6
1 3 -4 2 2 -2
Output #1
3
There are three contiguous subsequences whose sums are $0$: $(1,3,-4)$, $(-4,2,2)$ and $(2,-2)$.
Input #2
7
1 -1 1 -1 1 -1 1
Output #2
12
In this case, some subsequences that have the same contents but are taken from different positions are counted individually. For example, three occurrences of $(1, -1)$ are counted.
Input #3
5
1 -2 3 -4 5
Output #3
0
There are no contiguous subsequences whose sums are $0$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。