Divisible sub-array

#include
#include
#define ll long
using namespace std;
ll a[1000005],pre[1000005];
int main(){
int t;
cin>>t;
while(t–){
int n;
cin>>n;
memset(pre,0,sizeof(pre));
pre[0]=0;
int sum=0;
for(int i=0;i<n;i++){
cin>>a[i];
sum+=a[i];
sum%=n;
sum=(sum+n)%n; //ans should not be negative
pre[sum]++;
}
ll ans=0;
for(int i=0;i<n;i++){
ll m=pre[i];
ans+=m*(m-1)/2;
}
cout<<ans<<endl;
}

} whats wrong in this code?

line 29 should have paranthesis ( m * ( m-1))/2

and initiliase pre[0] = 1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.