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 |
字符串那么多, 一个int怎么可能表示得出来。重复是肯定有的, 不过可以多次hash来尽量避免重复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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator