Tuesday, 21 July 2015

CANDY3

Standard

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.

RECOMMENDED QUESTION :

I think you will like solving this question involving gcd.

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;
}

0 comments:

Post a Comment