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:Re:引起误解了,不好意思 Posted by:ArXoR at 2005-03-05 23:15:00 帮看一下巴 到底哪儿错了阿 #include <stdio.h> #include <math.h> int comp(void* a,void *b){ long *p=(long*)a; long *q=(long*)b; return *p>*q; } int main(){ long cow[10000],num,i,j; __int64 noise=(__int64)0; scanf("%d",&num); for(i=0;i<num;i++){ scanf("%d",&cow[i]); } qsort(cow,num,sizeof(long),comp); for(i=1;i<num;i++){ noise=noise+(__int64)2*i*(num-i)*(cow[i]-cow[i-1]); } printf("%I64d\n",noise); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator