| ||||||||||
| 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>
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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator