fork download
  1. def choose(m)
  2. self.factorial / (m.factorial * (self - m).factorial)
  3. end
  4. def fact (n)
  5. if n < 2
  6. return 1
  7. end
  8. (2..n).inject(1) { |f, n| f * n }
  9. end
  10. mod = 10**9 + 7
  11. t = gets.to_i
  12. while t > 0
  13.  
  14. s = gets.chomp
  15. if s.include 'j' || s.include 'J' || s.include 'u' || s.include 'U' || s.include 'w' || s.include 'W'
  16. puts "0"
  17. else
  18. m = n
  19.  
  20. count = []
  21. i = 0
  22. while s[i]!=nil
  23. count << s.count(s[i])
  24.  
  25. s = s.gsub(s[i],"")
  26.  
  27. end
  28. n = count.length
  29. deno = 1
  30. (0..n-1).each{ |i|
  31. deno = deno * fact(count[i])
  32.  
  33.  
  34. }
  35.  
  36. print "%d\n" %"#{(fact(m)/deno)%mod}"
  37.  
  38. end
  39. t= t - 1
  40. end
Runtime error #stdin #stdout 0s 4760KB
stdin
4
ab
aa
aA
AAbaz
stdout
Standard output is empty