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:不知道为什么排了序不行,暴搜反而可以... Posted by:yuanyirui at 2007-03-30 00:10:43 #include<stdio.h> #include<math.h> int main() { long int n,a[10001],i,j,sum; while(scanf("%ld",&n)!=EOF) { a[0]=0; for(i=1;i<=n;i++) scanf("%d",&a[i]); sum=0; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(i==j) continue; else sum+=abs(a[i]-a[j]); } } printf("%ld\n",sum); } return 1; } 好奇怪!!! 我和你的一样呀!!! 为什么我的超时!!! 哭....... Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator