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 |
无语,开始不知道有abs,用fabs超时,后来换成abs就ac了。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator