Initialize sum as zero for all test cases ie inside 1st for loop.
On Jun 21, 2012 5:22 PM, "Mayank Singh" <[email protected]> wrote:
> here is my code :
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int main()
> {
> long long cand,sum;
> int T,N,i,j,*temp;
> scanf("%d",&T);
> temp= (int*)calloc(T, sizeof( int));
> sum = 0;
> for(i=0;i<T;i++)
> {
> scanf("%d",&N);
> for(j=0;j<N;j++)
> {
> scanf("%lld",&cand);
> sum = (sum+cand)%N;
> }
> if(sum == 0)
> temp[i]=1;
> else
> temp[i]=0;
> }
> for(i=0;i<T;i++)
> {
> if(temp[i]==1)
> printf("YES\n");
> else
> printf("NO\n");
> }
> return 0;
> }
>
> it is giving WA in spoj. i am unable to find what is wrong with it..plz
> help me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.