const vc=1000000000;
var a:array[1..1000000] of longint;
m,n,min,res,d:longint;
procedure nhap;
begin
read(m,n);
end;
procedure tim_uoc;
var i:longint;
begin
d:=0;
for i:=1 to trunc(sqrt(m)) do
if m mod i = 0 then
begin
inc(d);
a[d]:=i;
inc(d);
a[d]:=m div i;
end;
end;
function ktnt(x:longint):boolean;
var i:longint;
begin
if x<=1 then exit(false);
for i:=2 to trunc(sqrt(x)) do
if x mod i = 0 then exit(false);
exit(true);
end;
procedure giai;
var i:longint;
begin
if m=1 then
begin
write(-1);
exit;
end;
min:=vc; res:=-1;
for i:=1 to d do
if ktnt(a[i])=true then
if(abs(a[i]-n)<min) then
begin
min:=abs(a[i]-n);
end;
if (ktnt(n-min)=true) and (m mod (n-min)=0) then
write(n-min,' ');
if (ktnt(n+min)=true) and (m mod (n+min)=0) then
write(n+min);
end;
begin
assign(input,'prime1195.inp');reset(input);
assign(output,'prime1195.out');rewrite(output);
nhap;
tim_uoc;
giai;
end.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Tư, 27 tháng 4, 2022
PRIME1195 Pascal
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.