Cod sursa(job #25383)

Utilizator CrusherTira Cristian Crusher Data 4 martie 2007 12:21:33
Problema Puteri Scor 20
Compilator fpc Status done
Runda preONI 2007, Runda 3, Clasa a 9-a si gimnaziu Marime 0.61 kb
var n,i,j,p,co,p2,p3,p5:integer;
    a,b,c:array[1..100] of integer;
function cmmdc(x,y:integer):integer;
var r:integer;
begin
while y<>0 do begin
  r:=x mod y;
  x:=y;
  y:=r;
end;
cmmdc:=x;
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
    p2:=a[i]+a[j];
    p3:=b[i]+b[j];
    p5:=c[i]+c[j];
    p:=cmmdc(p2,p3);
    if p<>1 then begin p:=cmmdc(p,p5);
      if p<>1 then inc(co);
    end;
  end;
writeln(co);
close(input); close(output);
end.