| ||||||||||
| 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 | |||||||||
貌似数组不需要用__int64类型。。。也不需要排序。。。。。。#include<iostream>
#include<cmath>
using namespace std;
const int MaxSize=10010;
int cow[MaxSize];//牛的编号,无重复、未排序
int main()
{
int i,j;
int n;
cin>>n;
for(i=0;i<n;i++)
scanf("%d",&cow[i]);
////////////////////////
__int64 sum=0;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
sum+=(2*abs(cow[j]-cow[i]));
}
}
printf("%I64d\n",sum);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator