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 |
不用什么排序,果断暴力!#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> int in[10000]; int main() { int n; __int64 sum=0; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&in[i]); } for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ sum+=abs(in[i]-in[j]); } } printf("%I64d\n",sum*2); // system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator