fork(2) download
  1. #include <set>
  2. #include <map>
  3. #include <list>
  4. #include <cmath>
  5. #include <queue>
  6. #include <stack>
  7. #include <cstdio>
  8. #include <string>
  9. #include <vector>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <sstream>
  13. #include <iomanip>
  14. #include <complex>
  15. #include <iostream>
  16. #include <algorithm>
  17.  
  18. #include <ctime>
  19. #include <deque>
  20. #include <bitset>
  21. #include <cctype>
  22. #include <utility>
  23. #include <cassert>
  24. using namespace std;
  25.  
  26. #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
  27. #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
  28. #define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
  29. #define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
  30. #define SZ(S) ((int) ((S).size()))
  31.  
  32. #define DEBUG(x) { cout << #x << " = " << x << endl; }
  33. #define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
  34. #define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
  35.  
  36. string s;
  37.  
  38. long long f[1011][1011];
  39.  
  40. int main() {
  41. ios :: sync_with_stdio(false); cin.tie(NULL);
  42. cout << (fixed) << setprecision(6);
  43. while (cin >> s) {
  44. int n = s.length();
  45. FORD(j,n-1,0) FORD(i,j-1,0) {
  46. int k = i + j + 1;
  47. if (k >= n) f[i][j] = s[j] * 311 + s[i];
  48. else f[i][j] = f[j][k] * 311 + s[i];
  49. }
  50. set<long long> s;
  51. REP(i,n) FOR(j,i+1,n-1)
  52. s.insert(f[i][j]);
  53.  
  54. cout << s.size() << endl;
  55. }
  56. return 0;
  57. }
  58.  
  59.  
Success #stdin #stdout 0s 11464KB
stdin
FAKE0123456789original
stdout
217