Facebook
From Innocent Prairie Dog, 3 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 180
  1. import math
  2. import collections
  3. s = input()
  4. c = collections.Counter(s)
  5. p = 10 ** 9 + 7
  6.  
  7. untanolist = ["D","S","R","X","Q"]
  8. a = min([c[i] for i in untanolist])
  9. ans = 0
  10. cnt = 0
  11. while cnt < a:
  12.     for i in untanolist:
  13.         c[i] -= 1
  14.     cnt += 1
  15.     kans = sum(c.values())
  16.     kans = math.factorial(kans+cnt)
  17.     kans //= math.factorial(cnt)
  18.     for i in c.values():
  19.         kans //= math.factorial(i)
  20.     ans = (ans + (-1)**(cnt+1) * kans) % p
  21. print(ans%p)

Replies to Untitled rss

Title Name Language When
Re: Untitled Funky Tapir python 3 Years ago.