fork download
  1. import string
  2. def factorial(x):
  3. ans = 1
  4. for i in range(1, x+1):
  5. ans *= i
  6. return ans
  7. t = input()
  8. for j in range(0, t):
  9. s = raw_input()
  10. count = [0]*256
  11.  
  12. for letter in string.ascii_letters:
  13. count[ord(letter)]++
  14. num = factorial(len(s))
  15.  
  16. den = 1
  17.  
  18. for i in range(0, 256):
  19. if(count[i]!=0):
  20. den *= factorial(count[i])
  21.  
  22. num /= den
  23. print num % 1000000007
Runtime error #stdin #stdout 0.03s 6352KB
stdin
1
ab
stdout
Standard output is empty