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.  
  11. t = gets.to_i
  12. while t > 0
  13.  
  14. s = gets.chomp
  15. n = s.length
  16. count = []
  17. i = 0
  18. while i < n
  19. count << s.count(s[i])
  20. t = s.count(s[i])
  21. s = s.gsub(s[i],"")
  22. i = i + t
  23. end
  24. n = count.length
  25. deno = 1
  26. (0..n-1).each{ |i|
  27. deno = deno * fact(count[i])
  28. puts fact(count[i])
  29. }
  30. puts "#{fact(n)}"
  31. t= t - 1
  32. end
Runtime error #stdin #stdout 0s 4760KB
stdin
4
ab
aa
aA
AAbaz
stdout
Standard output is empty