Pagini recente » Cod sursa (job #1403518) | Cod sursa (job #456202) | Cod sursa (job #1414691) | Cod sursa (job #2062450) | Cod sursa (job #31654)
Cod sursa(job #31654)
program puteri;
var a,b,c,a1,b1,c1,d:byte;
p,n,i,j,k:longint;
f,g:text;
function divizor2(a,b:byte):byte;
var d,min:byte;
gasit:boolean;
begin
d:=2;
gasit:=false;
if a=b then
divizor2:=a
else
if (a>1) and (b mod a=0) then
divizor2:=a
else
if (b>1) and (a mod b=0) then
divizor2:=b
else
begin
if a<b then
min:=a
else
min:=b;
while (d<=sqrt(min)) and not gasit do
if a mod d +b mod d =0 then
gasit:=true
else
inc(d);
if gasit then
divizor2:=d
else
divizor2:=1
end;
end;
function divizor(a,b,c:byte):byte;
var min,d:byte;
gasit:boolean;
begin
if (a=0) and (b=0) then
divizor:=c
else
if (c=0) and (b=0) then
divizor:=a
else
if (c=0) and (a=0) then
divizor:=b
else
if a=0 then
divizor:=divizor2(b,c)
else
if b=0 then
divizor:=divizor2(a,c)
else
if c=0 then
divizor:=divizor2(a,b)
else
begin
if a<b then
min:=a
else
min:=b;
if min>c then
min:=c;
d:=2;
gasit:=false;
while (d<sqrt(min)) and not gasit do
if a mod d +b mod d + c mod d =0 then
gasit:=true
else
inc(d);
if gasit then
divizor:=d
else
divizor:=1
end;
end;
begin
assign(f,'puteri.in');
reset(f);
assign(g,'puteri.out');
rewrite(g);
readln(f,n);
p:=0;
for i:=1 to n do
begin
reset(f);
for k:=1 to i do
readln(f);
readln(f,a,b,c);
for j:=i+1 to n do
begin
readln(f,a1,b1,c1);
a:=a+a1;
b:=b+b1;
c:=c+c1;
d:=divizor(a,b,c);
a:=a-a1;
b:=b-b1;
c:=c-c1;
if d>1 then
inc(p)
end;
end;
close(f);
writeln(g,p);
close(g);
end.