usaco 1.5 checker 2008.5.9

来源:互联网 发布:盗号用什么软件最好 编辑:程序博客网 时间:2024/06/06 17:40

usaco 1.5 checker 2008.5.9

{

ID:

PROG: checker

LANG: PASCAL

}

var t,up:longint; n:integer;

      r:array[1..13]of integer;

procedure pp(a,b,c,d:longint);

var pos,p:longint;

procedure print;

var i:longint;

begin

    for i:=1 to n-1 do write(r[i],' ');

    writeln(r[n]);

end;

begin

    if a<up then begin

    pos:=up and not(a or b or c);

    while pos<>0 do begin

         p:=pos and -pos;

         pos:=pos-p;

         if t<=3 then

         r[d]:=round(ln(p)/ln(2))+1;

         pp(a+p,(b+p)shr 1,(c+p)shl 1,d+1);

    end;

    end else begin inc(t);

    if t<=3 then

    print;end;

 

end;

begin

    assign(input,'checker.in');reset(input);

   assign(output,'checker.out');rewrite(output);

    readln(n);

    t:=0;

    up:=(1 shl n)-1;

    pp(0,0,0,1);

         writeln(t);

      close(input);close(output);

end.

0 0