LATGACH - Lát gạch

Tác giả: skyvn97

Ngôn ngữ: Pascal

program latgach;
uses crt;
type
    bignum=string;
const
     max=111;
var
   opt:array[1..max] of bignum;
   t,c,n:integer;
   a,b:bignum;
function bigplus(a,b:bignum):bignum;
         var
            i,carry,s:integer;
            result:bignum;
         begin
              result:='';
              while length(a)<length(b) do a:='0'+a;
              while length(b)<length(a) do b:='0'+b;
              carry:=0;
              for i:=length(a) downto 1 do
                  begin
                       s:=ord(a[i])+ord(b[i])+carry-96;
                       carry:=s div 10;
                       result:=chr(s mod 10+48)+result;
                  end;
              if carry=1 then result:='1'+result;
              bigplus:=result;
         end;
procedure init;
          var
             i:integer;
          begin
               opt[1]:='1';
               opt[2]:='2';
               for i:=3 to max do
                   opt[i]:=bigplus(opt[i-1],opt[i-2]);
          end;
begin
     init;
     readln(t);
     for c:=1 to t do
         begin
              readln(n);
              writeln(opt[n]);
         end;
end.

Download