szabivan

YODA

Oct 26th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char line[1024];
  5. int count[32];
  6. long long unsigned result,n;
  7. int odd;
  8.  
  9. int main( int argc, char* argv[] ){
  10. loop:
  11.     if( !gets( line ) ) return 0;
  12.     char *ptr = line;
  13.     memset( count, 0, sizeof(count) );
  14.     while( *ptr ){
  15.       if( (*ptr>='A') && (*ptr<='Z') ) { count[ *ptr - 'A' ]++; }
  16.       else if( (*ptr>='a') && (*ptr<='z') ) { count[ *ptr - 'a' ]++; }
  17.       ptr++;
  18.     }
  19.     odd = 0;
  20.     for( int i = 0; i < 26; i++ ){
  21.       if( count[i] & 1 ){
  22.         if( odd ){ printf("0\n"); goto loop; }
  23.         else odd = 1;
  24.       }
  25.       count[i] /= 2;
  26.     }
  27.     result = 1; n = 1;
  28.     for( int i = 0; i < 26; i++ ){
  29.       for( int j = 1; j <= count[i]; j++ ){
  30.         result *= (n++);
  31.         result /= j;
  32.       }
  33.     }
  34.     printf("%llu\n",result);
  35. goto loop;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment