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

暴力C500+MS,G++900+MS

Posted by cz_insane at 2013-01-22 21:22:29 on Problem 2231
#include<stdio.h>
#include<stdlib.h>

int i,j,n,a[10001];
long long ans;

int main(){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	ans=0;
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			ans+=abs(a[i]-a[j]);
		}
	}
	ans*=2;
	printf("%lld",ans);
	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