2013年2月21日

Codeforces Round #166 (Div. 2)D. Good Substrings(字符串散列)

摘要: D. Good Substringstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s 阅读全文

posted @ 2013-02-21 23:57 铁树银花 阅读(398) 评论(0) 推荐(0) 编辑

BKDR Hash Function

摘要: 字符串哈希函数繁多,据说在信息学竞赛中,高效而易于记忆的是BKDR Hash Function. 代码如下: 1 // BKDR Hash Function 2 int BKDRHash(char *str) 3 { 4 int seed = 131; // 31 131 1313 13131 131313 etc.. 5 int hash = 0; 6 7 while (*str) 8 { 9 hash = hash * seed + (*str++);10 }11 12 return (hash & 0x7FFFFFFF);... 阅读全文

posted @ 2013-02-21 21:05 铁树银花 阅读(1439) 评论(0) 推荐(0) 编辑

导航