Pagini recente » Cod sursa (job #2627822) | Cod sursa (job #2958270) | Cod sursa (job #3203562) | Cod sursa (job #3279515) | Cod sursa (job #466352)
Cod sursa(job #466352)
var f,i,j,k,min,max:longword;
n:qword;
v:array of int64;
x,y,xx,yy,m:int64;
procedure fib(x:qword);
begin
setlength(v,5);
k:=1;
v[1]:=1;
inc(k);
v[k]:=2;
while v[k]<x do
begin
v[k+1]:=v[k]+v[k-1];
inc(k);
setlength(v,k+2);
end;
end;
begin
assign(input,'fibo3.in');
assign(output,'fibo3.out');
reset(input);
rewrite(output);
read(n);
fib(1000000000000000);
for i:=1 to n do
begin
m:=0;
read(x,y,xx,yy);
for j:=1 to k do
if v[j]>=x+y then
begin
if (v[j]-x<=yy)and(v[j]-y<=xx)and(v[j]-y>=0)and(v[j]-x>=0) then
begin
m:=m+(yy-y)+1;
//writeln(m,' ',v[j]);
end
else
if ((v[j]-x)-yy+x<=xx)and((v[j]-y)-xx+y<=xx) then
if ((v[j]-x)-yy+x)-(v[j]-((v[j]-y)-xx+y))>0 then
m:=m+((v[j]-x)-yy+x)-(v[j]-((v[j]-y)-xx+y));
end;
writeln(m);
end;
close(output);
end.