fork download
  1. #include<bits/stdc++.h>
  2. #include<cstdio>
  3. #include<cstring>
  4.  
  5. #define X first
  6. #define Y second
  7. #define eb push_back
  8. #define siz(a) int(a.size())
  9.  
  10. #define trace2(x, y) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
  11. #define trace3(x, y, z) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
  12. #define trace4(a, b, c, d) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
  13. #define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
  14.  
  15. using namespace std;
  16.  
  17. typedef long long int ll;
  18. typedef vector < int > vi;
  19. typedef vector < ll > vll;
  20.  
  21. const int mod=1e9+7;
  22. const int maxn=1e6+5;
  23.  
  24. ll fact[25];int cnt[30];
  25. char str[maxn];
  26. int main(){
  27. ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  28. //freopen("input.in", "r", stdin);
  29. //freopen("output.out", "w", stdout);
  30.  
  31. fact[0] = 1;
  32. fact[1] = 1;
  33. for(int i = 2; i<21; i++){
  34. fact[i] = i*fact[i-1];
  35. // trace2(i, fact[i]);
  36. }
  37.  
  38. while(1){
  39. gets(str);
  40. if(feof(stdin)) break;
  41. for(int i = 0; i<26; i++)
  42. cnt[i] = 0;
  43. int size = strlen(str);
  44. for(int i = 0; i<size; i++){
  45.  
  46. if(str[i] >= 'a' && str[i] <= 'z'){
  47. cnt[str[i] - 'a']++;
  48. }
  49.  
  50. if(str[i] >= 'A' && str[i] <= 'Z'){
  51. cnt[str[i] - 'A']++;
  52. }
  53.  
  54. }
  55.  
  56. int total = 0, odd = 0;
  57.  
  58. for(int i = 0; i<26; i++){
  59. if(cnt[i]){
  60. total += cnt[i];
  61.  
  62. if(cnt[i]%2)
  63. odd++;
  64. }
  65. }
  66. if(odd > 1)
  67. cout << "0" << endl;
  68. else{
  69. ll ans = fact[(total/2)];
  70. // assert(total <= 40);
  71. for(int i = 0; i<26; i++){
  72. // assert(cnt[i] <= 40);
  73.  
  74. ans /= fact[(cnt[i]>>1)];
  75. }
  76. cout << ans << endl;
  77. }
  78. }
  79.  
  80. return 0;
  81. }
  82.  
Success #stdin #stdout 0s 3856KB
stdin
Standard input is empty
stdout
Standard output is empty