const max = 100; var str: string; chars: array[1..max] of char; count: array[1..max] of byte; charsC: byte; i,j: byte; odd, oddc: byte; res: longint; F: Text; begin Assign(F, 'D.in'); Reset(F); Read(F, str); Close(F); FillChar(chars, max, 0); FillChar(count, max, 0); CharsC:=0; for i := 1 to Length(str) do begin for j:= 1 to charsC do if chars[j]=str[i] then break; if chars[j]=str[i] then begin count[j]:=count[j]+1; end else begin CharsC:=CharsC+1; chars[CharsC] := str[i]; count[CharsC] := 1; end; end; oddc := 0; for i := 1 to CharsC do begin if count[i] mod 2 = 1 then begin odd := i; oddc := oddc+1; end; count[i] := count[i] div 2; end; res := 0; if (oddc=1) and (charsc=1) then res:=1 else if (oddc < 2) and (charsc > 0) then begin res := 1; for i := charsc downto 1 do begin if count[i]>0 then begin res := (res * i) mod (1000*1000*1000); for j := 2 to count[i] do res := (res * j) mod (1000*1000*1000); end; end; end; Assign(F, 'D.out'); Rewrite(F); Writeln(f, res); Close(F); end. |