-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCHEFARRP
More file actions
42 lines (30 loc) · 659 Bytes
/
CHEFARRP
File metadata and controls
42 lines (30 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
using namespace std;
int main()
{
int t,n,i,j,flag;
cin>>t;
while(t--)
{
cin>>n;
int a[n], b[n], c[n];
flag=0;
for(i = 0; i < n; i++) cin>>a[i];
for(j = 1; j < n; j++){
b[j-1]=a[j-1];
c[j-1]=a[j-1];
for(i = j; i < n; i++)
{ b[i] = 0;
c[i] = 1;
if(a[i]+b[i-1] == c[i-1]*a[i])
{
flag++;
}
b[i] = a[i]+b[i-1];
c[i] = c[i-1]*a[i];
}
}
cout<<flag+n<<endl;
}
return 0;
}