BASEH - Cơ số H

Tác giả: ll931110

Ngôn ngữ: Pascal

Program BASEH;
        Const
                input  = '';
                output = '';
        Var
                h,k,digit: longint;
                        a: array[1..32] of byte;

Procedure init;
          Var
                f: text;
          Begin
                Assign(f, input);
                        Reset(f);
                        Readln(f, k, h);
                Close(f);
          End;

Procedure solve;
          Begin
                digit:= 0;

                Repeat
                        inc(digit);
                        If odd(k) then a[digit]:= 1 else a[digit]:= 0;
                        k:= k div 2;
                Until k = 0;
          End;

Procedure printresult;
          Var
                  f: text;
                  i: integer;
          Begin
                Assign(f, output);
                        Rewrite(f);
                        For i:= digit downto 1 do write(f, a[i]);
                Close(f);
          End;

Begin
        init;
        solve;
        printresult;
End.

Download