1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include <iostream> #include <cstdio> #include <cmath> #include <climits> #include <inttypes.h> #include <cstring> #include <string> #include <algorithm> #define INF 1000000 #define _MOD 1000000007 #define ul unsigned long long using namespace std; int arr[105]; unsigned long long ncr[105][105]; /* void init() { ncr[1][1]=1; for(int i=2;i<105;i++) { ncr[i][1]=i; for(int j=2;j<=i;j++) { ncr[i][j] = ( (ncr[i-1][j-1]%_MOD) + (ncr[i-1][j]%_MOD) )%_MOD; } } } */ int main() { int t,kase=1,n; ul ans; scanf("%d",&t); //init(); while(t--) { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&arr[i]); } sort(arr+1,arr+n+1); ans = 1; for(int i=1;i<=n;i++) { if(arr[i]<i) { ans = 0; break; } ans = (ans*(arr[i]-i+1))%_MOD; } printf("Case %d: %llu\n",kase++,ans); } return 0; } |