uses crt;
var manga,mangb:array[1..100] of integer;
checka,checkb:array[1..100] of boolean;
i,j,a,b,dema,demb,kqa,kqb: integer;
hp: boolean;
procedure timuoc;
begin
dema:=0;
for i:=2 to a do
if a mod i = 0 then
begin
dema:=dema+1;
manga[dema]:=i;
end;
demb:=0;
for i:=2 to b do
if b mod i = 0 then
begin
demb:=demb+1;
mangb[demb]:=i;
end;
end;
Procedure uocnguyento;
begin
for i:=1 to dema do
begin
checka[i]:=true;
if manga[i]=2 then checka[i]:=true else
for j:=2 to trunc(sqrt(manga[i])) do
if manga[i] mod j = 0 then checka[i]:=false;
end;
kqb:=0;
for i:=1 to demb do
begin
checkb[i]:=true;
if mangb[i]=2 then
checkb[i]:=true else
for j:=2 to trunc(sqrt(mangb[i])) do
if mangb[i] mod j = 0 then
checkb[i]:=false;
end;
end;
procedure ghi;
begin
writeln(' uoc cua so a la :');
kqa:=0;
for i:=1 to dema do
if checka[i] = true then begin
kqa:=kqa+1;
write(manga[i],', ');
end;
writeln;
writeln(' uoc cua b :');
kqb:=0;
for i:=1 to demb do
if checkb[i]=true then
begin kqb:=kqb+1;
write(mangb[i],', '); end;
writeln;
end;
procedure xuli;
begin
if kqa <> kqb then writeln(' khong phai hai so nguyen to tuong duong ');
if kqa=kqb then
begin
for i:=1 to dema do
for j:=1 to demb do
if manga[i]=mangb[j] then hp:=true; end;
if hp=true then writeln('dung la hai so nguyen to tuong duong ') else writeln('khong phai');
end;
BEGIN
readln(a,b);
timuoc;
uocnguyento;
ghi;
xuli;
readln;
end.