1458:Seek the Name, Seek the Fame
#include"iostream"
#include<cstring>
using namespace std;
using ULL=unsigned long long;
const int P=131;
const int N=4e5+10;
ULL p[N],h[N];
char s[N];
void gethash()
{
int len=strlen(s+1);
p[0]=1,h[0]=0;
for(int i=1;i<=len;i++)
{
p[i]=p[i-1]*P;
h[i]=h[i-1]*P+s[i];
}
}
ULL get(int l,int r)
{
return h[r]-h[l-1]*p[r-l+1];
}
int main()
{
while(~scanf("%s",s+1))
{
memset(p,0,sizeof p);
gethash();
int len=strlen(s+1);
for(int i=0;i<len;i++)
{
if(get(1,1+i)==get(len-i,len))
printf("%d ",i+1);
}
printf("\n");
}
return 0;
}