Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

那位大哥帮我看一下,本地都是对的,提交就是WA

Posted by jian at 2005-07-21 02:22:43 on Problem 2231

#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator