Pagini recente » Cod sursa (job #1176588) | Cod sursa (job #2945189) | Cod sursa (job #1802854) | Cod sursa (job #247931) | Cod sursa (job #25540)
Cod sursa(job #25540)
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.