Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define MOD 1000000007
  3. using namespace std;
  4.  
  5. int sz[100001];
  6. long long fact[100001];
  7.  
  8. long long cnt(int n, int k) {
  9. return (fact[n] / fact[k]) / fact[n-k];
  10. }
  11.  
  12. int main() {
  13. int n, m; // n - size of field, m - count of arrays.
  14. cin >> n >> m;
  15.  
  16. fact[0] = 1;
  17. fact[1] = 1;
  18. for(long long i = 2; i <= n; i++) fact[i] = (fact[i-1]*i)%MOD;
  19.  
  20. for(int i = 0; i < m; i++) {
  21. cin >> sz[i];
  22. }
  23.  
  24. long long ans = 1;
  25. for(int i = 0; i < m; i++) {
  26. ans *= cnt(n, sz[i]);
  27. n -= sz[i];
  28. }
  29.  
  30. cout << ans << endl;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement