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

无语,开始不知道有abs,用fabs超时,后来换成abs就ac了。

Posted by tanjing at 2010-09-15 16:45:46 on Problem 2231
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
	int n;
	cin>>n;
	long long sum=0;
	int m[10000];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&m[i]);
		for(int j=0;j<i;j++)
		{
			sum+=abs(m[i]-m[j]);
		}
	}
	sum=sum*2;
	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