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???????#include<stdio.h> #include<stdlib.h> int cmp(const void*a,const void*b) { return *(int*)b-*(int*)a ; } int main() { int a[20001]; int i,j,k,n,m; __int64 sum=0; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); qsort(a,n,sizeof(int),cmp); for(i=0;i<n;i++) sum+=a[i]; sum*=(n-1); for(i=n;i>1;i--) sum-=a[n-i]*(i-2);//重复加的 printf("%I64d",sum); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator