#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll c[102][102];
void binomial()
{
int i, j;
c[0][0] = 1;
for(i=1;i<=101;i++)
{
c[i][0] = c[i][i] = 1;
for(j=1;j<i;j++)
c[i][j] = c[i-1][j-1]+c[i-1][j];
}
}
int main()
{
binomial();
ll n, m, i;
while(cin >> n >> m)
{
int a[m];
ll r = 1;
for(i=0;i<m;i++)
{
cin >> a[i];
r *= c[n][a[i]];
n = n - a[i];
}
cout << r << endl;
}
return 0;
}
#define ll unsigned long long int
using namespace std;
ll c[102][102];
void binomial()
{
int i, j;
c[0][0] = 1;
for(i=1;i<=101;i++)
{
c[i][0] = c[i][i] = 1;
for(j=1;j<i;j++)
c[i][j] = c[i-1][j-1]+c[i-1][j];
}
}
int main()
{
binomial();
ll n, m, i;
while(cin >> n >> m)
{
int a[m];
ll r = 1;
for(i=0;i<m;i++)
{
cin >> a[i];
r *= c[n][a[i]];
n = n - a[i];
}
cout << r << endl;
}
return 0;
}
Comments
Post a Comment