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

貌似数组不需要用__int64类型。。。也不需要排序。。。。。。

Posted by lithum at 2009-08-10 17:57:59 on Problem 2231
#include<iostream>
#include<cmath>
using namespace std;

const int MaxSize=10010;

int cow[MaxSize];//牛的编号,无重复、未排序

int main()
{
	int i,j;
	int n;
	cin>>n;
	for(i=0;i<n;i++)
		scanf("%d",&cow[i]);
	////////////////////////
	__int64 sum=0;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			sum+=(2*abs(cow[j]-cow[i]));
		}
	}
	printf("%I64d\n",sum);
	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