SlepoiKrot

Untitled

Mar 5th, 2018
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program time;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. var
  9.   n: integer;
  10.   function step (n: integer): int64;
  11.     var
  12.       i: integer;
  13.       a: array [1..36] of int64;
  14.     begin
  15.       a[1] := 1;
  16.       a[2] := 2;
  17.       a[3] := 4;
  18.       for i := 4 to n do begin
  19.         a[i] := a[i-1] + a[i-2] + a[i-3];
  20.       end;
  21.       result := a[n];
  22.     end;
  23. begin
  24.   readln (n);
  25.   writeln (step(n));
  26.   readln;
  27. end.
RAW Paste Data