CID vs Terrorists
All submissions for this problem are available.
ACP Pradyumn is on his way to catch the mastermind behind the Hyderabad bomb blasts.
The mastermind, on the other hand, challenges the ACP by generating a sequence of numbers for him.
There is a sequence of n numbers, which can be both positive and negative. The task is to find the number of continuous sequence of numbers such that their sum is zero.
For example if the sequence is: 5, 2, -2, 5, -5, 9 There are 3 such sequences 2, -2 5, -5 2, -2, 5, -5
Since the ACP is having difficulty in solving the problem, he asks for your help. Your goal is to find number of such sequences to help the ACP in catching the terrorist.
First line contains T - number of test cases Second line contains n - the number of elements in a particular test case. Next line contain n elements, ai (1<=i<= n) separated by spaces.
The number of such sequences whose sum if zero.
1<=t<=5 1<=n<=10^6 -10<= ai <= 10
Input: 2 4 0 1 -1 0 6 5 2 -2 5 -5 9 Output: 6 3
|Time Limit:||0.105172 - 0.351677 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, GO|
Fetching successful submissions