Pagini recente » Cod sursa (job #160482) | Cod sursa (job #1057142) | Cod sursa (job #177636) | Cod sursa (job #2961290) | Cod sursa (job #603489)
Cod sursa(job #603489)
program pascal;
var
cifra1,cifra2:array[0..5000000] of integer;
r,i,j,x:longint;
d:byte;
count:integer;
f,g:text;
begin
assign(f,'pascal.in');
assign(g,'pascal.out');
reset(f);
read(f,r);
read(f,d);
close(f);
cifra1[1]:=1;
x:=1;
if r<>0 then
repeat
x:=x+1;
for i:=1 to x do
cifra2[i]:=cifra1[i]+cifra1[i-1];
for i:=1 to x do
cifra1[i]:=cifra2[i];
until x=r+1;
rewrite(g);
for i:=1 to x do
begin
if cifra1[i]<>0 then
if cifra1[i] mod d=0 then
count:=count+1;
end;
write(g,count);
close(g);
end.