LATGACH - Lát gạch
Tác giả: ll931110
Ngôn ngữ: Pascal
Program LATGACH;
Const
Input = '';
Output = '';
Var
d,test: array[1..100] of byte;
F: array[1..100,1..30] of byte;
i,n: integer;
Procedure enter;
Var
fi: text;
i: integer;
Begin
Assign(fi, input);
Reset(fi);
Readln(fi, n);
For i:= 1 to n do readln(fi, test[i]);
Close(fi);
Fillchar(F, sizeof(F), 0);
End;
Procedure calc;
Var
i,j: integer;
Begin
F[1,1]:= 1; d[1]:= 1;
F[2,1]:= 2; d[2]:= 1;
For i:= 3 to 100 do
Begin
For j:= 1 to d[i - 1] do
Begin
F[i,j]:= F[i,j] + F[i - 1,j] + F[i - 2,j];
If F[i,j] > 9 then
Begin
F[i,j + 1]:= 1;
F[i,j]:= F[i,j] - 10;
End;
End;
d[i]:= d[i - 1];
If F[i, d[i - 1] + 1] <> 0 then inc(d[i]);
End;
End;
Procedure printresult;
Var
fo: text;
i,j: integer;
Begin
Assign(fo, output);
Rewrite(fo);
For i:= 1 to n do
Begin
For j:= d[test[i]] downto 1 do write(fo, F[test[i],j]);
Writeln(fo);
End;
Close(fo);
End;
Begin
enter;
calc;
printresult;
End.