Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Fibbonachi;
- {$APPTYPE CONSOLE}
- function CountIsAnswer(x, y: Integer; CoefY, CoefX: Integer; const N: Integer): Integer;
- begin
- repeat
- Result := CoefX * x + CoefY * y;
- if Result = N then
- begin
- Result := 0;
- Write(CoefX,' ', CoefY);
- end;
- Inc(CoefY);
- until N > Result;
- end;
- type
- TFibArr = array of Integer;
- var
- N, AverageI: Int64;
- i, j: Integer;
- IsFind: Boolean;
- FibArr: TFibArr;
- begin
- Readln(N);
- IsFind := False;
- SetLength(FibArr, N div 2);
- FibArr[0] := 1;
- FibArr[1] := 1;
- i := 2;
- while N > FibArr[i] do
- begin
- FibArr[i] := FibArr[i - 1] + FibArr[i - 2];
- Inc(i);
- end;
- i := 0;
- while N > FibArr[i] do
- begin
- if N = FibArr[i] then
- begin
- Write('0 1');
- IsFind := True;
- end;
- if FibArr[i] < N div 2 then
- AverageI := i + 2;
- Inc(i);
- end;
- i := AverageI;
- while not IsFind do
- begin
- j := 0;
- while (i > j) do
- begin
- IsFind := (ord(IsFind) = CountIsAnswer(FibArr[i - 1], FibArr[i], 1, j, N));
- Inc(j);
- end;
- Dec(i);
- end;
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement