Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MOD 1000000007
- using namespace std;
- int sz[100001];
- long long fact[100001];
- long long cnt(int n, int k) {
- return (fact[n] / fact[k]) / fact[n-k];
- }
- int main() {
- int n, m; // n - size of field, m - count of arrays.
- cin >> n >> m;
- fact[0] = 1;
- fact[1] = 1;
- for(long long i = 2; i <= n; i++) fact[i] = (fact[i-1]*i)%MOD;
- for(int i = 0; i < m; i++) {
- cin >> sz[i];
- }
- long long ans = 1;
- for(int i = 0; i < m; i++) {
- ans *= cnt(n, sz[i]);
- n -= sz[i];
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement