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 |
那位大哥帮我看一下,本地都是对的,提交就是WA#include<iostream.h> int main() { long array[10000]; long arr[10000]; long num; long i; cin>>num; long k; for(i=0;i<num;i++)cin>>array[i]; for(i=0;i<num;i++) for(k=i;k<num;k++) { long temp; if(array[i]>array[k]) { temp=array[k]; array[k]=array[i]; array[i]=temp; } } for(i=0;i<num-1;i++)array[i]=array[i+1]-array[i]; for(i=0;i<num-1;i++) { if(i==0)arr[i]=num-1; else { arr[i]=arr[i-1]-i+(num-i-1); } } long all=0; for(i=0;i<num-1;i++)all+=array[i]*arr[i]; all=all*2; cout<<all<<endl; return 1; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator