Guest User

Untitled

a guest
Mar 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. from collections import Counter
  2. MOD, N = 10**9 + 7, 10**5 + 2
  3. fact = [1] + [j for j in [1] for i in xrange(1, N) for j in [(j * i) % MOD]]
  4. inv = [pow(fact[i], MOD - 2, MOD) for i in xrange(N)]
  5. def C(h, k): return (fact[h] * inv[k] * inv[h - k]) % MOD
  6. n, d = raw_input(), Counter(map(int, raw_input().split())).most_common()
  7. print (reduce(lambda x, y: (x * C(d[0][1], y[1]) * fact[y[1]]) % MOD, d, 1) * inv[d[0][1]]) % MOD
Add Comment
Please, Sign In to add comment