Cod sursa(job #466260)

Utilizator tibi9876Marin Tiberiu tibi9876 Data 26 iunie 2010 12:38:20
Problema Fibo3 Scor 30
Compilator fpc Status done
Runda Stelele Informaticii 2010, gimnaziu si clasa a IX-a, Ziua 2 Marime 0.7 kb
var s,x1,x2,y1,y2,n,i:longint;

procedure rezolvare(min1,min2,max1,max2:longint);
var j,max,min,x,y,z:longint;
begin
x:=1;
y:=1;
z:=2;
while y<min1+min2 do
begin
x:=y;
y:=z;
z:=x+y;
end;
while y<=max1+max2 do
begin
for j:=min1 to max1 do
if (min2<=y-j) and (max2>=y-j) then inc(s);
x:=y;
y:=z;
z:=x+y;
end;
writeln(s);
s:=0;
end;

begin
assign(input,'fibo3.in');reset(input);
assign(output,'fibo3.out');rewrite(output);
readln(n);
s:=0;
for i:=1 to n do
begin
readln(x1,y1,x2,y2);
if (x1>x2) and (y1>y2) then rezolvare(x2,y2,x1,y1)
else if (x1<x2) and (y1>y2) then rezolvare(x1,y2,x2,y1)
else if (x1>x2) and (y2>y1) then rezolvare(x2,y1,x1,y2)
else rezolvare(x1,y1,x2,y2);
end;
end.