1451 - Sum
Time Limit : 2 Second
Memory Limit : 128 MB
Submission: 10
Solved: 9
- Description
Given a sequence a [1], a [2], a [3]......a[n], your job is to calculate how many sub-sequence whose summation is equal to SUM.
We define a sub-sequence of the sequence is a[i],a[i+1]...a[j-1],a[j] ( i <= j ).And the number of this sub-sequence is j-i+1.
- Input
The first line of the input contains an integer T (1<=T<=10) which means the number of test cases. Then T lines follow, each line starts with a number N (1<=N<=100000), then N integers followed (all the integers are between 0 and 1000).
- Output
For each test case, you should output one line. The line is a number about how many sub-sequences whose summation is equal to SUM.
- sample input
-
3 3 2 1 1 2 3 3 1 1 2 3 0 0 0 0
- sample output
-
2 1 6
- hint
- source