不是VIP会员,不能显示答案

题目解答

题目:
Program xx2010_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 find:=0
else begin
m:=h+f[i-1]-1;
count:=count+1;
if x=a[m] then find:=m
else if x<a[m] then find:=find(i-1,h,x)
else find:=find(i-2,m+1,x);
end;
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);
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);
end.
【输入】:
8 14 7
输出:5 2
0 4
考点:
分析:
解答:
评论:
老师: