Candy III
Link to the question : CANDY3
HINT :
The question sounds very easy. And yes it is quite simple. Just be careful about the large input size and where to use the modulo function.
SOURCE CODE :
#include<iostream>
using namespace std;
int main()
{
long long t,n,s,*a,i;
cin>>t;
cout<<endl;
while(t--)
{
cin>>n;
a= new (nothrow)long long[n];
s=0;
for(i=0;i<n;i++)
{
cin>>a[i];
s=(s+a[i])%n;
}
if(s%n==0)
cout<<"YES"<<endl<<endl;
else
cout<<"NO"<<endl<<endl;
}
return 0;
}
why can't we just use a variable instead of a[i] ?
ReplyDelete