-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshassandlght.cpp
More file actions
executable file
·47 lines (41 loc) · 868 Bytes
/
shassandlght.cpp
File metadata and controls
executable file
·47 lines (41 loc) · 868 Bytes
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
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;
ll n,m,nCr[1001][1001],ans=1,s[1001],p[1001];
int main(){
cin >> n >> m;
for(int i=0;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
if(j==0 || j==i)
nCr[i][j]=1;
else
nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j])%M;
}
}
p[0]=1;p[1]=1;
for(int i=2;i<=n;i++)
p[i]=(p[i-1]*2)%M;
for(int i=0;i<m;i++)
cin>>s[i];
sort(s,s+m);
ll cur=0,tmp;
for(int i=0;i<m;i++)
{
if(i==0)
tmp=s[i]-1;
else
{
tmp=s[i]-s[i-1]-1;
ans=(ans*p[tmp])%M;
}
cur+=tmp;
ans=(ans*nCr[cur][tmp])%M;
}
cur+=n-s[m-1];
ans=ans*nCr[cur][n-s[m-1]]%M;
cout << ans << endl;
return 0;
}