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 |
Re:这样也错了In Reply To:那个牛人帮我看看哪里错了,总是WRONG.或给点测试数据. Posted by:JNUZL at 2007-09-18 22:36:11 > #include <iostream.h> > #include <stdio.h> > #include <stdlib.h> > int cmp(const void *a, const void *b) > { > return(*(long *)b-*(long *)a); > } > int main() > {int i,n,j; > long a[20010]; > __int64 sum=0,t=0; > while(scanf("%d",&n)!=EOF) > {sum=0;t=0; > for(i=0;i<n;i++) > {scanf("%ld",&a[i]); > t=t+a[i]; > } > qsort(a,n,sizeof(a[0]),cmp); > sum=sum+t; > for(j=0;j<n-2;j++) > {t=t-a[j]; > sum=sum+t; > } if(n==1) printf("0\n"); else > printf("%I64d\n",sum); > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator