Pagini recente » Cod sursa (job #1233273) | Cod sursa (job #746188) | Cod sursa (job #737783) | Cod sursa (job #1560227) | Cod sursa (job #492013)
Cod sursa(job #492013)
var r,d:longint;
f,g:text;
function calcul(r:longint;d:word):word;
var i,j:longint;
p:longint;
nr,max:word;
begin
nr:=0;
p:=1;
for i:=1 to r-1 do
begin
if r-i>=i then
max:=r-i
else
if r-i<i then
max:=i;
p:=1;
for j:=max+1 to r do
p:=p*j;
for j:=2 to r-max do
p:=p div j;
if p mod d=0 then
inc(nr);
end;
calcul:=nr;
end;
begin
assign(f,'pascal.in');
reset(f);
assign(g,'pascal.out');
rewrite(g);
readln(f,r,d);
writeln(g,calcul(r,d));
close(f);
close(g);
end.