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 200531200326 at 2010-07-24 09:58:57 on Problem 2231
#include <iostream>
using namespace std;
int pos[10000];
int main()
{
	int N;
	long long sum=0;
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>pos[i];
	}
	for(int i=1;i<=N;i++)
	{
		for(int j=i+1;j<=N;j++)
		{
			sum+=2*abs(pos[j]-pos[i]);
		}
	}
	cout<<sum<<endl;
	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