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:是不是qsort(cow,num,sizeof(long),comp);错了,把long改__int64试试In Reply To:那位帮看一下吧 到底哪里错了 wa了n次了 Posted by:waternet at 2005-03-05 23:28:24 > #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