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