fork(1) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <stack>
  12. #include <list>
  13. #include <cmath>
  14. #include <iomanip>
  15. #define dibs reserve
  16. #define OVER9000 123456789012345678LL
  17. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  18. #define tisic 47
  19. #define soclose 1e-8
  20. #define chocolate win
  21. // so much chocolate
  22. #define patkan 9
  23. #define ff first
  24. #define ss second
  25. #define abs(x) ((x < 0)?-(x):x)
  26. #define uint unsigned int
  27. #define dbl long double
  28. using namespace std;
  29. // mylittledoge
  30.  
  31. int main() {
  32. cin.sync_with_stdio(0);
  33. cin.tie(0);
  34. string s;
  35. cin >> s;
  36. int N =s.length();
  37. set< pair<long long, long long> > S[2000];
  38. for(int a =1; a <= N; a++) for(int b =a+1; b <= N; b++) {
  39. long long h1 =0, h2 =0;
  40. int x =a, y =b, l =0;
  41. while(x <= N) {
  42. l++;
  43. int a =s[x-1]-'a'+1;
  44. if(s[x-1] >= '0' && s[x-1] <= '9') a =40+s[x-1]-'0';
  45. if(s[x-1] >= 'A' && s[x-1] <= 'Z') a =60+s[x-1]-'A';
  46. h1 =(h1*999983+a)%1000000009;
  47. h2 =(h2*4521+a+2)%1000000007;
  48. int z =x+y;
  49. x =y;
  50. y =z;}
  51. S[l].insert(make_pair(h1,h2));}
  52. int ans =0;
  53. for(int i =0; i <= 1000; i++) ans +=S[i].size();
  54. cout << ans << "\n";
  55. return 0;}
  56.  
  57. // look at my code
  58. // my code is amazing
  59.  
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
0