I just tried to understand this code but I can't somebody can explain me what happen in this 2 line in for function.
#include <cstdio>
char s[5005000];
int h[5005000];
const int M=3;
int main() {
scanf("%s",s);
int a=0,b=0,p=1,v=0;
for(int i=0;s[i];++i){
a=a*M+s[i],b+=s[i]*p,p*=M;
if(a==b)v+=(h[i+1]=h[(i+1)>>1]+1);
}
printf("%d\n",v);
return 0;
}
thankk you for your explanation!
Aucun commentaire:
Enregistrer un commentaire