all persons said this there is something wrong in candy3spoj.pl/problems/CANDY3/
this is my code and it is right (i am sure)
#include<stdio.h> #include<iostream> using namespace std; int main() { int t,i; cin>>t; for(i=0;i<t;i++) { long long n; cin>>n; long long sum=0,j,k; for(j=0;j<n;j++) { cin>>k; sum+=k; } int q=sum%n; if(q==0) { cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } } return 0; }
i guess input is very large. sum may exceed range of long long. ( HINT : sum % n will not exceed the range. )
there is no other solutions except (long long) it is the greatest!!!!
( a1 + a2 + a3 + .... + an ) % n = ??there is an alternative to solve sum % n. think . read comments below the problem and you might click the idea.
i have wa not tle
why????
and i used modular with long long as written in comments
when sum exceeds range of long long it takes any integer garbage value which leads to WA.
i cant't help you further after this.
23 + 31 = 54, 54 % 5 = 4 23 % 5 = 3, 31 % 5 = 1, 3+1 = 4
thx very much i understand u