Pagini recente » Cod sursa (job #2840508) | Cod sursa (job #2633949) | Cod sursa (job #121394) | Cod sursa (job #536735) | Cod sursa (job #16591)
Cod sursa(job #16591)
rogram nsdl;
var f,g:text;
a:array[1..100000] of longint;
b:array[1..2] of qword;
n,i,j,k,l,m,nr:longint;
begin
assign(f,'pascal.in');
assign(g,'pascal.out');
reset(F);
rewrite(G);
readln(f,n,m);
b[1]:=1; a[1]:=1;a[2]:=1;
if n=1 then writeln(g,0)
else
begin
for i:=2 to n-1 do
begin
a[1]:=1; a[i+1]:=1;
for j:=2 to i do
begin
b[2]:=a[j];
a[j]:=(a[j]+b[1]) mod m;
b[1]:=b[2];
end;
end;
nr:=0;
for i:=1 to n do
if a[i] mod m=0 then nr:=nr+1;
writeln(g,nr);
end;
close(F);
close(G);
end.