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

Re:不知道为什么排了序不行,暴搜反而可以...

Posted by yanchao at 2007-08-23 11:15:53 on Problem 2231
In Reply To:不知道为什么排了序不行,暴搜反而可以... Posted by:yuanyirui at 2007-03-30 00:10:43
#include<stdio.h>
#include<math.h>
int main()
{
	long int n,a[10001],i,j,sum;
	while(scanf("%ld",&n)!=EOF)
	{
	a[0]=0;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sum=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i==j) continue;
			else
				sum+=abs(a[i]-a[j]);
		}
	}
	printf("%ld\n",sum);
	}
	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