Equal Sum and Product
Submissions: 1374   Accuracy:

49.1%

  Difficulty: Easy   Marks: 2

Given an array, return the count of number of contiguous subarrays for which the sum and product of elements are equal.

Input:

The first line of input contains an integer T denoting the number of test cases. T test cases follow. The first line of each test contains the integer N. The next line contains N integers — A1A2, ..., AN — denoting the array.


Output:

For each testcase, output a single line containing the answer.


Constraints:

1<=T<=100
1<=N<=10
1<=A[i]<=10  (1 <= i <= N)


Example:

Input:
1
5
1 2 3 4 5

Output:
6

Explanation:

In the sample testcase, all 6 subarrays having sum of elements equals to the product of elements are :
{1}, {2}, {3}, {4}, {5}, {1,2,3}

** For More Input/Output Examples Use 'Expected Output' option **

Author: dipjal1996


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.