字符串哈希
参考资料
实现
using ull=unsigned long long;
const int base=131;
const ull mod=212370440130137957;
ull get_hash(string s)
{
ull res=0;
for(int i=0;i<s.size();i++)
{
res=(res*base+s[i])%mod;
}
return res;
}
例题
如题,给定 个字符串(第 个字符串长度为 ,字符串内包含数字、大小写字母,大小写敏感),请求出 个字符串中共有多少个不同的字符串。Code (1)
给定 个字符串,判断不同的字符串有多少个。Code (1)