Pagini recente » Cod sursa (job #425144) | Cod sursa (job #2169512) | Cod sursa (job #1536121) | Cod sursa (job #498367) | Cod sursa (job #1182093)
Program paskal;
var i,n,p,k1 : longint;
M : array [0..5000005] of longint;
function fact(n : longint) : longint;
var aux,i : longint;
begin
aux:=1;
if n>0 then
for i:=1 to n do aux:=aux*i;
fact:=aux;
end;
begin
assign(input,'pascal.in'); reset(input);
assign(output,'pascal.out'); rewrite(output);
readln(n,p);
for i:=0 to n do
M[i]:=fact(n)div(fact(n-i)*fact(i));
for i:=1 to n-1 do
if M[i] mod p=0 then k1:=k1+1;
writeln(k1);
close(input);
close(output);
end.