Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不用什么排序,果断暴力!

Posted by m6106918 at 2011-04-09 20:37:45 on Problem 2231
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator