| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
秀代码的又来了#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
int main()
{
//ifstream cin("0000.txt");
int n,aa[10000];
cin>>n;
for(int i=0;i<n;i++)
cin>>aa[i];
sort(aa,aa+n);
unsigned long long sum=0,temp;
for(int i=n-2;i>=0;i--)
{temp=(aa[i+1]-aa[i]);
sum+=temp*(n-i-1)*(i+1);
}
cout<<sum*2<<endl;
//system("pause");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator