Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char line[1024];
- int count[32];
- long long unsigned result,n;
- int odd;
- int main( int argc, char* argv[] ){
- loop:
- if( !gets( line ) ) return 0;
- char *ptr = line;
- memset( count, 0, sizeof(count) );
- while( *ptr ){
- if( (*ptr>='A') && (*ptr<='Z') ) { count[ *ptr - 'A' ]++; }
- else if( (*ptr>='a') && (*ptr<='z') ) { count[ *ptr - 'a' ]++; }
- ptr++;
- }
- odd = 0;
- for( int i = 0; i < 26; i++ ){
- if( count[i] & 1 ){
- if( odd ){ printf("0\n"); goto loop; }
- else odd = 1;
- }
- count[i] /= 2;
- }
- result = 1; n = 1;
- for( int i = 0; i < 26; i++ ){
- for( int j = 1; j <= count[i]; j++ ){
- result *= (n++);
- result /= j;
- }
- }
- printf("%llu\n",result);
- goto loop;
- }
Advertisement
Add Comment
Please, Sign In to add comment