ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1196. History Exam

Problem 'bout Hash.. (|8-1
Posted by yangdong 21 Oct 2010 13:36
I've seen a discussion that
gave a Hash Function .... as this:    x& 2^31
but As the writer say..the tests are too weak..got AC
Is there  any better Hash?...like ELF in string Hash..
touch me Please.

Edited by author 21.10.2010 13:37
Re: Problem 'bout Hash.. (|8-1
Posted by KALO 21 Oct 2010 22:27
These should be better:

string s;
longint x:=0;
for i:=1 to lenght(s) do
 x:=s[i]+(x shl 6) + (x shl 16) -x;

or

longint b:=3737 or b:=1717
x:=0;
for i:=1 to length(s) do
begin
 x:=x*b;
 x:=x+s[i];
end;

Edited by author 21.10.2010 22:30

Edited by author 21.10.2010 22:33

Edited by author 21.10.2010 22:35