fork download
  1.  
  2. def choose(m)
  3. self.factorial / (m.factorial * (self - m).factorial)
  4. end
  5. def fact (n)
  6. if n < 2
  7. return 1
  8. end
  9. (2..n).inject(1) { |f, n| f * n }
  10. end
  11. mod = 10**9 + 7
  12. t = gets.to_i
  13. while t > 0
  14.  
  15. s = gets.chomp
  16. n = s.length
  17. m = n
  18. count = []
  19. i = 0
  20. while i < n
  21. count << s.count(s[i])
  22.  
  23. i = i + s.count(s[i])
  24. end
  25. n = count.length
  26. deno = 1
  27. (0..n-1).each{ |i|
  28. deno = deno * fact(count[i])
  29.  
  30. }
  31. puts count
  32. #print "#{(fact(m)/deno)%mod}\n"
  33. t= t - 1
  34. end
Success #stdin #stdout 0s 4760KB
stdin
1
AAabbb
stdout
2
1
3