比赛 20101105 评测结果 WAWWTTTWTA
题目名称 倒水 最终得分 20
用户昵称 ZhouZn1 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-05 20:52:32
显示代码纯文本
program zzn;
var
        i,j,k,n,s,n2,ans,s2:longint;
procedure init;
begin
        assign(input,'watera.in');
        reset(input);
        assign(output,'watera.out');
        rewrite(output);
        readln(n,k);
end;
procedure closef;
begin
        close(input);
        close(output);
end;
{procedure main;
begin
        n2:=n;
        s:=0;
        ans:=0;
while true do
begin
        while n2 mod 2 =0 do
         begin
             inc(s);
             n2:=n2 div 2;
             if n2<=k then
              begin
                  writeln(ans);
                  exit;
              end;
         end;
         s2:=trunc(exp(s*ln(2)));
        inc(ans,s2);
        inc(n2);
end;
        writeln(ans);
end; }
procedure main;

begin
        for i:=0 to 100000000 do
         begin
          n2:=n+i;
          while n2 mod 2=0 do
           begin
               n2:=n2 div 2;
           end;
          if n2<=k then
           begin
               writeln(i);
               exit;
           end;
         end;
end;
begin
        init;
        main;
        closef;
end.