Pagini recente » Monitorul de evaluare | Monitorul de evaluare | Monitorul de evaluare | Probleme de Taietura | Cod sursa (job #201751)
Cod sursa(job #201751)
#include<stdio.h>
#define nmax 100024
bool ok[nmax];
int sol[nmax];
const int much=1000003;
int main()
{freopen("gropi.in","r",stdin);
freopen("gropi.out","w",stdout);
int N,M;
scanf("%d%d",&N,&M);
int i,a1;sol[1]=1;
while( M-- ){
scanf("%d",&a1);
ok[a1]=true;
}
for(i=2; i<=N; ++i){
if( ok[i] )
sol[i]=sol[i-1];
else{
sol[i]=sol[i-1]*(i-1);
sol[i]%=much;}
}
printf("%d\n",sol[N]);
return 0;
}