[r]
(1)Bài 11/1999 - Dãy số Fibonaci (Dành cho học sinh THCS) {$R+}
const
Inp = 'P11.INP'; Out = 'P11.OUT'; Ind = 46;
var
n: LongInt;
Fibo: array[1 Ind] of LongInt; procedure Init;
var
i: Integer; begin
Fibo[1] := 1; Fibo[2] := 1;
for i := to Ind Fibo[i] := Fibo[i - 1] + Fibo[i - 2]; end;
procedure Solution; var
i: LongInt; hfi, hfo: Text; begin
Assign(hfi, Inp); Reset(hfi); Assign(hfo, Out); Rewrite(hfo);
while not Eof(hfi) begin
Readln(hfi, n); Write(hfo, n, ' = ');
i := Ind; while Fibo[i] > n Dec(i); Write(hfo, Fibo[i]);
Dec(n, Fibo[i]); while n > begin
Dec(i);
if n >= Fibo[i] then begin
(2)Dec(n, Fibo[i]); end;
end;
Writeln(hfo); end;
Close(hfo); Close(hfi); end;