Cod sursa(job #28259)

Utilizator cristi_oocnean cristian cristi_o Data 7 martie 2007 17:30:13
Problema Puteri Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.61 kb
program puteri;
type sir=array[1..100000] of byte;
var a,b,c:sir;
    f,g:text;
    n:longint;

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

procedure verificare;
var i,j,sa,sb,sc,t,aux:longint;
begin
t:=0;
assign (g,'puteri.out'); rewrite (g);
for i:=1 to n do begin
   for j:=i+1 to n do
                    begin sa:=a[i]+a[j];
                          sb:=b[i]+b[j];
                          sc:=c[i]+c[j];
   if (sa=sb) and (sb=sc) and (sb>1) then inc (t)
    else
      if (sa mod 2=0) and (sb mod 2=0) and (sc mod 2=0) then inc (t)
        {else
          if (sa<sb) and (sa<sc) then
            if (sb mod sa>1) and (sc mod sa>1) then inc (t)}
         else begin
           if sa<sb then begin aux:=sa;
                               sa:=sb;
                               sb:=aux
                            end;
           if sa<sc then begin aux:=sc;
                                sc:=sa;
                                sa:=aux;
           end;
           if sb<sc then begin aux:=sb;
                                 sb:=sc;
                                 sc:=aux
           end;
           if sc>0 then
              if (sc>1)and(sa mod sc=0) and (sb mod sc=0) then inc (t)
                                                 else
           else
              if sb=0 then if sa>1 then inc (t) else
                      else if (sa mod sb=0)and(sb>1) then inc (t);
        end;
      end;
end;
write (g,t);
close (g);
end;

begin
citire;
verificare;
end.