Skip to content

Instantly share code, notes, and snippets.

@pranet
Created March 14, 2018 21:01
Show Gist options
  • Select an option

  • Save pranet/4f6f1c7b9da82a0175f4a11d0ea155ce to your computer and use it in GitHub Desktop.

Select an option

Save pranet/4f6f1c7b9da82a0175f4a11d0ea155ce to your computer and use it in GitHub Desktop.
from collections import Counter
MOD, N = 10**9 + 7, 10**5 + 2
fact = [1] + [j for j in [1] for i in xrange(1, N) for j in [(j * i) % MOD]]
n, d = raw_input(), Counter(map(int, raw_input().split())).most_common()
print (reduce(lambda x, y: (x * fact[d[0][1]] * pow(fact[d[0][1] - y[1]], MOD - 2, MOD)) % MOD, d, 1) * pow(fact[d[0][1]], MOD - 2, MOD)) % MOD
@xennygrimmato

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment