-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf_B.cpp
43 lines (39 loc) · 834 Bytes
/
cf_B.cpp
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
43
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int n,c=0,f=0;
cin>>n;
long long int a[n],p[n+1];
p[0]=0;
for(int i=0; i<n; i++)
{
cin>>a[i];
p[i+1]=p[i]+a[i];
}
for(int i=0; i<n; i++)
{
if(p[n]==a[i])
f=1;
}
for(int i=0; i<n; i++)
{
if(a[i]==0) c++;
}
if(c==n) cout<<n<<endl;
else if(f) cout<<c+1<<endl;
else if(!f&&n%2!=0) cout<<c<<endl;
else if(!f&&n%2==0) cout<<2*c<<endl;
}
}
/*else if(c%2==0&&n%2!=0)
cout<<c+1<<endl;
else if(c%2==0&&n%2==0)
cout<<c*2<<endl;
else if(c%2!=0)
cout<<c<<endl;
*/