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

为什么hash超时 帮忙看看啊,大哥大姐们,发现问题的发我邮箱,谢谢了~~~

Posted by liguanbin at 2007-08-10 15:28:54 on Problem 2769
#pragma warning(disable:4786)
#include<stdio.h>
#include <map>
using namespace std;
typedef map<int,int> intmap;
typedef intmap::value_type maptype;
int main()
{int i,j,k,l;
long a[300];
int num;
int num1;
int flag=0;
intmap temp;
scanf("%d",&num);
for(i=0;i<num;i++)
{scanf("%d",&num1);
for(j=0;j<num1;j++)
scanf("%d",&a[j]);

for(k=num1;;k++)
{
	temp.clear();
	for(l=0;l<num1;l++)
	{
		temp[a[l]%k]++;
		if(temp[a[l]%k]>1)break;
	}
	if(l==num1){printf("%d\n",k);break;}
}

}
return 0;
}

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