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

字符串那么多, 一个int怎么可能表示得出来。重复是肯定有的, 不过可以多次hash来尽量避免重复

Posted by chaeyeon at 2008-11-26 17:43:36 on Problem 2503
In Reply To:这题竟然可以发现标准hash的bug...... Posted by:alawing at 2008-11-26 15:06:19
> 经过我提交本题20+次
> 加上搜索网上数据得出
> int ELFhash(char* key)
> {
> 	unsigned long h = 0;
> 	while(*key)
> 	{
> 		h = (h<<4) + *key++;
> 		unsigned long g = h & 0Xf0000000L;
> 		if(g)
> 			h ^= g >> 24;
> 		h &= ~g;
> 	}
> 	return h % M;
> }
> 这个hash算法有覆盖= =;
> 例如eeeeeefvnb eeeeeegfnb这2个hash值竟然一样(函数里h算出来的就一样)
> 厄。。。。。
> 

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