

Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 点
問題文
長さ の整数列 があります。
の 空でない 連続する 部分列であって、その総和が になるものの個数を求めてください。 ただし、ここで数えるのは 部分列の取り出し方 であることに注意してください。 つまり、ある つの部分列が列として同じでも、取り出した位置が異なるならば、それらは別々に数えるものとします。
制約
- 入力はすべて整数である。
入力
入力は以下の形式で標準入力から与えられる。
出力
の空でない連続する部分列であって、その総和が になるものの個数を出力せよ。
入力例 1Copy
6 1 3 -4 2 2 -2
出力例 1Copy
3
空でない連続した部分列であって、その総和が になるのは、, , の つです。
入力例 2Copy
7 1 -1 1 -1 1 -1 1
出力例 2Copy
12
この例では、列として同じだが取り出す位置の異なる部分列が複数回数えられています。 例えば、 は 回数えられています。
入力例 3Copy
5 1 -2 3 -4 5
出力例 3Copy
0
空でない連続した部分列であって、その総和が になるものはありません。
Score : points
Problem Statement
We have an integer sequence , whose length is .
Find the number of the non-empty contiguous subsequences of whose sums are . 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
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Find the number of the non-empty contiguous subsequences of whose sum is .
Sample Input 1Copy
6 1 3 -4 2 2 -2
Sample Output 1Copy
3
There are three contiguous subsequences whose sums are : , and .
Sample Input 2Copy
7 1 -1 1 -1 1 -1 1
Sample Output 2Copy
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 are counted.
Sample Input 3Copy
5 1 -2 3 -4 5
Sample Output 3Copy
0
There are no contiguous subsequences whose sums are .