Tiêu đề: bai 11: vu hoai bang Tue Dec 27, 2022 2:10 pm
Code:
var a:array[1..1000,1..1000] of longint; n,m,i,j,p:longint; function nt(n:longint):boolean; var i:longint; begin if n<=1 then exit(false); if (n=2) or (n=3) then exit(true); if (n mod 2=0) or (n mod 3=0) then exit(false); i:=5; while i*i<=n do begin if (n mod i=0) or (n mod (i+2)=0) then exit(false); inc(i,6); end; exit(true); end; begin assign(input,'bai3onl.inp');reset(input); assign(output,'bai3onl.out');rewrite(output); read(n,m); for i:=1 to n do for j:=1 to m do read(a[i,j]); p:=0; for i:=1 to n do for j:=1 to m do if nt(a[i,j]) then begin p:=1; writeln(i,' ',j); end; if p=0 then write('-1'); close(input);close(output); end.