Pagini recente » Cod sursa (job #2836519) | Cod sursa (job #1477133) | Cod sursa (job #1687029) | Cod sursa (job #1444345) | Cod sursa (job #1182092)
Program paskal;
var i,j,n,k,p,k1 : longint;
M,L : array [0..5000005] of longint;
begin
assign(input,'pascal.in'); reset(input);
assign(output,'pascal.out'); rewrite(output);
readln(n,p);
M[0]:=0;
M[1]:=1;
M[2]:=1;
M[3]:=0;
k:=3;
for i:=1 to n-1 do begin
for j:=1 to k do L[j]:=M[j-1]+M[j];
for j:=1 to k do M[j]:=L[j];
M[0]:=0;
M[k+1]:=0;
k:=k+1;
end;
for i:=1 to k-1 do
if L[i] mod p=0 then k1:=k1+1;
writeln(k1);
close(input);
close(output);
end.