Skip to content

Instantly share code, notes, and snippets.

@alexkay alexkay/gist:1600348
Created Jan 12, 2012

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:
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
You can’t perform that action at this time.