Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Code Sprint 2 - Picking Cards
#!/usr/bin/env python
def calc(a, n):
res = 1
m = 1
for i in xrange(n):
m -= 1
for k in xrange(i + m, n):
if a[k] > i:
break
m += 1
if m == 0:
return 0
res *= m
res %= 1000000007
return res
T = input()
for t in xrange(T):
n = input()
a = sorted([int(i) for i in raw_input().split()])
print calc(a, n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment