📅  最后修改于: 2022-03-11 14:44:55.449000             🧑  作者: Mango
long long compute_hash(string const& s) {
const int p = 53;
const int m = 1e9 + 9;
long long hash_value = 0;
long long p_pow = 1;
for (char c : s) {
hash_value = (hash_value + (c - 'a' + 1) * p_pow) % m;
p_pow = (p_pow * p) % m;
}
return hash_value;
}