构建hash
has[i]=has[i-1]*p+a[i-1]-'a';
就这个式子 计算
long long cal(int x,int y){ return has[y]-has[x-1]*pf[y-x+1]; }
判断是否存在一个长度为x的循环节 if(cal(l+x,r)==(l,r-x))
========= 以上
构建hash
has[i]=has[i-1]*p+a[i-1]-'a';
就这个式子 计算
long long cal(int x,int y){ return has[y]-has[x-1]*pf[y-x+1]; }
判断是否存在一个长度为x的循环节 if(cal(l+x,r)==(l,r-x))
========= 以上