**#include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int N=4e5+10; const ull B=131; char s[N];(#include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int N=4e5+10; const ull B=131; char s[N]; ull h[N],p[N]; int main(){ p[0]=1; for(int i=1;i<N;i++){ p[i]=p[i-1]*B; } while(scanf("%s",s+1)==1){ int n=strlen(s+1); h[0]=0; for(int i=1;i<=n;i++){ h[i]=h[i-1]*B+(ull)(s[i]); } for(int i=1;i<=n;i++){ if(h[i]==h[n]-h[n-i]*p[i]){ printf("%d ",i); } } cout<<endl; } return 0; }) ull h[N],p[N]; int main(){ p[0]=1; for(int i=1;i<N;i++){ p[i]=p[i-1]*B; } while(scanf("%s",s+1)==1){ int n=strlen(s+1); h[0]=0; for(int i=1;i<=n;i++){ h[i]=h[i-1]B+(ull)(s[i]); } for(int i=1;i<=n;i++){ if(h[i]==h[n]-h[n-i]p[i]){ printf("%d ",i); } } cout<<endl; } return 0; }

0 条评论

目前还没有评论...