fork download
  1. #include <string.h>
  2. #include <algorithm>
  3. #include <stdio.h>
  4.  
  5. using namespace std;
  6.  
  7. typedef long long ll;
  8.  
  9. const int MAXN = 4e5 + 5, BASE = 26;
  10. const ll MOD = 1000000007LL;
  11.  
  12. char str[MAXN];
  13. ll powers[MAXN];
  14.  
  15. int main(){
  16. powers[0] = 1;
  17. for(int i=1; i<MAXN-1; ++i) powers[i] = (powers[i - 1] * BASE) % MOD;
  18. while(scanf("%s", str) != EOF){
  19. int N = strlen(str);
  20. ll pre = 0, suf = 0;
  21. int i = 0, j = N - 1;
  22. while(i <= N - 1 && j >= 0){
  23. pre = (pre + (1LL * (str[i] - 'a' + 1) * powers[i]) % MOD) % MOD;
  24. suf = ((suf * BASE) % MOD + 1LL * (str[j] - 'a' + 1)) % MOD;
  25. if(pre == suf) printf("%d ", i + 1);
  26. i++, j--;
  27. }
  28. puts("");
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 6984KB
stdin
Standard input is empty
stdout
Standard output is empty