MULONE - Nhân 1

Tác giả: flashmt

Ngôn ngữ: Pascal

const d='1234567898765432';
      c2='123456790123456790';
      b2='098765432098765432';
      c='123456790';
      b='098765432';
      c1:array[1..9] of byte=(1,2,3,4,5,6,7,9,0);
      b1:array[1..9] of byte=(0,9,8,7,6,5,4,3,2);
var n,k,p,q,j,i,t:longint;

begin
     readln(k);
     for i:=1 to k do
     begin
          readln(n);
          p:=(n-1) div 9;
          q:=(n-1) mod 9;
          t:=p div 2;
          for j:=1 to t do write(c2);
          if p mod 2 = 1 then write(c);
          if q=8 then write(d)
          else
          begin
               for j:=1 to q do write(c1[j]);
               for j:=10-q to 9 do write(b1[j]);
          end;
          for j:=1 to t do write(b2);
          if p mod 2 = 1 then write(b);
          writeln(1);
     end;
end.

Download