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

Re:Notice~cout就过了,prinf就wa了n遍。。。

Posted by like680623 at 2011-01-17 20:05:32 on Problem 2231
#include<iostream>
#include<algorithm>
using namespace std;
int num[10005];
int main()
{
	int n;
	long long  sum = 0;
	cin>>n;
	for (int i = 0; i < n; i++)
		cin>>num[i];
	sort(num, num + n);
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			sum += num[j] - num[i];
	//printf("%d\n", sum * 2);
	cout<<sum * 2<<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