没有模的版本
const int N = 1000010 ;
const int m = 131 ;
const int mod = 1e9 + 7 ;
int n, T ;
char s[N] ;
int f[N], p[N] ;
int main() {
scanf("%s", s + 1) ; n = strlen(s + 1) ;
p[0] = 1 ;
for (int i = 1; i <= n; i++) {
f[i] = f[i - 1] * m + s[i] - 'a' + 1 ;
p[i] = p[i - 1] * m;
}
scanf("%d", &T) ;
while (T--) {
int a, b, c, d ; scanf("%d%d%d%d", &a, &b, &c, &d) ;
if (f[b] - f[a - 1] * p[b - a + 1] == f[d] - f[c - 1] * p[d - c + 1]) puts("Yes") ;
else puts("No") ;
}
}
标签:1000010,const,int,scanf,哈希,字符串
From: https://www.cnblogs.com/lighthqg/p/17623598.html