Pagini recente » Cod sursa (job #1586673) | Cod sursa (job #948196) | Cod sursa (job #170506) | Cod sursa (job #2792958) | Cod sursa (job #25137)
Cod sursa(job #25137)
var n,i,j,c1,rez,a1,b1,cmdc:longint;
a,b,c:array [1..100000] of longint;
function cmmdc (var x,y:longint):longint;
var r:longint;
begin
if (x=1) or (y=1) then begin cmmdc:=1; exit; end;
r:=x mod y;
while r>0 do begin
x:=y;
y:=r;
r:=x mod y;
end;
cmmdc:=y;
end;
begin
assign (input,'puteri.in'); reset (input);
assign (output,'puteri.out'); rewrite (output);
readln (n);
for i:=1 to n do
readln (a[i],b[i],c[i]);
for i:=1 to n-1 do
for j:=i+1 to n do begin
a1:=a[i]+a[j]; b1:=b[i]+b[j];
if (a1<>0) and (b1<>0) then cmdc:=cmmdc (a1,b1)
else cmdc:=abs (a1-b1);
c1:=c[i]+c[j];
if c1<>0 then
if cmmdc (c1,cmdc)>1 then inc (rez)
else
if (cmdc>1) then inc (rez);
end;
writeln (rez);
close (input); close (output);
end.