Skip to content

Instantly share code, notes, and snippets.

@alexkay
Created January 12, 2012 12:56
Show Gist options
  • Save alexkay/1600348 to your computer and use it in GitHub Desktop.
Save alexkay/1600348 to your computer and use it in GitHub Desktop.
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