陈凯斌吧 关注:9贴子:84
  • 1回复贴,共1
  • 202.101.104.*
var  t:array[1..100] of longint;
     n,a,b,i:longint;
procedure hnt(a,b:longint);
var k,i,j,o:longint;
begin
   for i:=1 to a do
    begin

     k:=b mod (t[i]*3);
     if (k=1) or (k=6) then write(1,' ');
     if (k=2) or (k=5) then write(2,' ');
     if (k=3) or (k=4) then write(3,' ');
    end;
end;
begin
    read(n);  t[1]:=1;
    for i:=2 to 20 do t[i]:=t[i-1]*3;
    for i:=1 to n do
     begin
      read(a,b);
      if (b=0) then for i:=1 to a do write(1,' ') else hnt(a,b);
     end;
end.


1楼2008-09-02 18:11回复
    var q,t:array[1..100] of longint;
    n,a,b,i,j:longint;
    procedure hnt(a,b:longint);
    var k,i,j,o:longint;
    begin
    b:=b+1;
    for i:=1 to a do
    begin
     for o:=1 to 6 do
     begin q[o]:=t[i] div 3; q[o]:=q[o]*o; end;
    k:=b mod (t[i]*2);
    if ((k<=(q[1])) and (k>=1)) or (k=0) or
     ((k>q[5]) and (k<q[6])) then write(1,' ');
    if ((k>q[1]) and (k<=q[2])) or
     ((k>q[4]) and (k<=q[5])) then write(2,' ');
    if ((k>q[2]) and (k<=q[4])) then write(3,' ');
    end;
    end;
    begin
    read(n);
    t[1]:=3;
    for i:=2 to 15 do t[i]:=t[i-1]*3;
    for i:=1 to n do
    begin
    read(a,b);
    if (b=0) then for j:=1 to a do write(1,' ') else hnt(a,b);
    end;
    end.


    禁言 |2楼2008-09-02 21:46
    回复