Cod sursa(job #25540)

Utilizator coderninuHasna Robert coderninu Data 4 martie 2007 12:53:29
Problema Puteri Scor 0
Compilator fpc Status done
Runda preONI 2007, Runda 3, Clasa a 10-a Marime 1.19 kb
program puteri;
type nr=0..64;
     nr2=1..100000;
     tripl=record
            a,b,c:nr;
           end;
var x:array [nr2] of tripl;
    i,j,n,rez:nr2;
    fin,fout:text;
    temp:tripl;

{-----------------------------}

procedure citire;
begin
 assign(fin,'puteri.in'); reset(fin);
 readln(fin,n);
 for i:=1 to n do
     readln(fin,x[i].a,x[i].b,x[i].c);
 close(fin);
end;

{-------------------------------}

procedure sum(o,p:nr2);
begin
 temp.a:=x[o].a+x[p].a;
 temp.b:=x[o].b+x[p].b;
 temp.c:=x[o].c+x[p].c;
end;

{-------------------------------}

function put(y:tripl):boolean;
var min:word;
begin
 min:=maxint;
 if (y.a<>0) and (y.a < min) then min:=y.a;
 if (y.b<>0) and (y.b < min) then min:=y.b;
 if (y.c<>0) and (y.c < min) then min:=y.c;
 put:=false;
 if min=1 then put:=false
          else if ((y.a mod min =0) and (y.b mod min =0) and (y.c mod min =0)) then put:=true;
end;


{-------------------main------------------}


begin
 citire;
 for i:=1 to n-1 do
     for j:=i+1 to n do
         begin
         sum(i,j);
         if put(temp) then inc(rez);
         end;
 assign(fout,'puteri.out'); rewrite(fout);
 write(fout,rez);
 close(fout);
end.