题目: |
Program cz2010_4;
var f:array[1..46]of longint;
a:array[1..100]of longint;
x,y,z,i,j,n,count:longint;
function find(i,h,x:longint):longint;
var m:longint;
begin
if i<3 then exit(0);
m:=h+f[i-1]-1; count:=count+1;
if x=a[m] then exit(m);
if x<a[m] then exit(find(i-1,h,x))
else exit(find(i-2,m+1,x));
end;
begin
f[1]:=1;f[2]:=1;
for i:=3 to 46 do f[i]:=f[i-1]+f[i-2];
readln(n,x,y,z);
for i:=1 to n do a[i]:=3*i-1;
i:=1;
while f[i]-1<n do inc(i);
for j:=n+1 to f[i]-1 do a[j]:=maxlongint;
count:=0; j:=find(i,1,x);
writeln(j,' ',count); count:=0;
j:=find(i,1,y); writeln(j,' ',count); count:=0;
j:=find(i,1,z); writeln(j,' ',count);
end.
【输入】
8 14 7 17 输出:5 2
0 4
6 4
|