Created
January 12, 2012 12:56
-
-
Save alexkay/1600348 to your computer and use it in GitHub Desktop.
Code Sprint 2 - Picking Cards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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