fork download
  1. #include<bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. #define int long long
  6. void file() {
  7. #ifndef ONLINE_JUDGE
  8. freopen("input.txt", "r", stdin);
  9. freopen("output.txt", "w", stdout);
  10. // freopen("errors.txt", "w", stderr);
  11. #endif
  12. }
  13. string s;
  14. bool is_pali(string now) {
  15. string co=now;
  16. reverse(co.begin(), co.end());
  17. return co==now;
  18. }
  19. int rec(int i=0,string now="") {
  20. if (i==s.size()) {
  21. if (now.size() && is_pali(now))
  22. return 1;
  23. return 0;
  24. }
  25. int a=rec(i+1,now+s[i]);
  26. int b=rec(i+1,now);
  27. return a+b;
  28. }
  29. void solve(){
  30. cin>>s;
  31. cout<<rec()<<endl;
  32. }
  33.  
  34. signed main() {
  35. file();
  36. int off = 1;
  37. cin>>off;
  38. while (off--)
  39. solve();
  40. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
0