字符串Hash模板
程序员文章站
2022-07-15 14:14:59
...
#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll gethash(char *s,int m){
ll h=0;
for(int i=0;s[i];i++)
h=((h<<8)+s[i])%m;
return h;
}
int main(){
#ifdef LOCAL
//freopen("C:/Users/Administrator/Desktop/input.txt","r",stdin);
#endif
char a[100]="22222222222222222222222222222";
char b[100]="22222222222222222222222223222";
printf("%lld\n",gethash(a,1e9+7));
printf("%lld\n",gethash(b,1e9+7));
}
上一篇: 告别CTO,体验创业维艰
下一篇: [模板] 字符串hash