Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why wa#include <stdio.h> #include <stdlib.h> #include <string.h> int num[21]={0},count=0; int cmp ( const void *a , const void *b ) { return *(int *)a - *(int *)b; } void main() { int n,m,j,i,t; long max=0,len; scanf("%d",&n); for(t=0;t<n;t++) { scanf("%d",&m); for(j=0;j<m;j++) { scanf("%d",&num[j]); max+=num[j]; } if(max%4!=0) { printf("no\n"); goto a; } else len=max/4; qsort(num,m,sizeof(num[0]),cmp); i=0;j=m-1; while(i<=j) { if(num[i]==len) { i++;count++; } else if(num[j]==len) { j--;count++; } else if((num[i]+num[j])>len) break; else if((num[i]+num[j])==len) { i++;j--; count++; } else i++; } if(count==4) printf("yes\n"); else printf("no\n"); a: memset(num,0,m);count=0;max=0; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator