Pagini recente » Cod sursa (job #2532963) | Cod sursa (job #2738713) | Cod sursa (job #1596329) | Cod sursa (job #1660650) | Cod sursa (job #145411)
Cod sursa(job #145411)
program gaju;
type tip=0..7;
var f,g:text;
n,x,aux,t,d,i:longint;
k,c:tip;
found,int:boolean;
begin
assign(f,'divprim.in');
assign(g,'divprim.out');
reset(f);
rewrite(g);
readln(f,t);
for i:=1 to t do begin
readln(f,n,k);
if (k<>0)and(n>1) then begin
found:=false;
for x:=n downto 2*k do begin
aux:=x;c:=0;
d:=2;int:=false;
while aux<>1 do begin
while aux mod d=0 do begin
aux:=aux div d;
int:=true;
end;
d:=d+1;
if int then c:=c+1;
int:=false;
end;
if c=k then begin
found:=true;
writeln(g,x);
break;
end;
end;
if not found then writeln(g,'0');
end
else writeln(g,'0');
end;
close(g);
end.