Start: Feb, 20, 2019 12:00:00
2018-2019 ACM集训队冬季集训第一次考核
End: Feb, 20, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: E
Result: Accepted
Time: 481ms
Memory: 64348kB
Author: 2015210402108
In contest: 1260

#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
typedef long long ll;

const int inf = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int MAXN = 4000005;
const int MAXM = 100000 + 10;
const double PI = acos(-1);
const double eps = 1e-8;

ll fact[MAXN], inv[MAXN];
ll c(ll n, ll m) { return n >= m ? 1LL * fact[n] * inv[n - m] % MOD*inv[m] % MOD : 0; }

int main() {
	ll n, m, ans = 1, x;
	scanf("%lld%lld",&n, &m);
	fact[0] = 1; for (int i = 1; i <= n * 4; i++) fact[i] = fact[i - 1] * i%MOD;
	inv[1] = 1; for (int i = 2; i <= n * 4; i++) inv[i] = inv[MOD%i] * (MOD - MOD / i) % MOD;
	inv[0] = 1; for (int i = 1; i <= n * 4; i++) inv[i] = inv[i - 1] * inv[i] % MOD;
	for (int i = 1; i <= m; ++i) {
		scanf("%lld", &x);
		ans = ans * (13 - i + 1) % MOD * c(n * 4, x) % MOD;
	}
	printf("%lld\n", ans);
}