Pagini recente » Cod sursa (job #2759269) | Cod sursa (job #2975911) | Cod sursa (job #2974753) | Cod sursa (job #3039457) | Cod sursa (job #197654)
Cod sursa(job #197654)
program grigo;
var n,m,i,a:longint;
poz: array[1..100000] of byte;
function permut(n:longint):int64;
var p :int64;
i:longint;
begin
p:=1;
for i:= 2 to n do
p:=p*i;
permut:=p;
end;
function con(a,n:longint):int64;
begin
if n = 1 then
con:=a
else
if n=a then
con:= 1
else
begin
if n=2 then
con:=(a-1)*(a) div 2;
end;
end;
Function calculeaza(n:longint):int64;
begin
i:=1;
while poz[i+1]=1 do
inc(i);
calculeaza:=permut(n-m)*con(n-m+i-1,i-1);
end;
begin
assign(input,'grigo.in'); reset(input);
assign(output,'grigo.out'); rewrite(output);
readln(n,m);
for i := 1 to m do
begin
read(a);
poz[a]:=1;
end;
if (poz[1]=0) and (m<>0) then
writeln(0)
else
writeln(calculeaza(n));
close(output);
close(input);
end.