WA5 What is wrong? help pls.

var n,k,ch,im:int64;

begin

read(n,k);

n:=n-1;

ch:=0;

im:=1;

while n>0 do begin

if im<=k then begin

n:=n-im;

im:=im*2;

ch:=ch+1;

end;

if im>k then begin

n:=n-k;

im:=im+k;

ch:=ch+1;

end;

end;

writeln(ch);

end.

Re: WA5 What is wrong? help pls.

well, i've also had WA 5, i tried to enter 4 2 and got 3 instead of 2. i found the mistake but then i got WA 14. i tried 6 4 and got 4 instead of 3 and understood that i had corrected the code wrong and only then i got AC.

*Edited by author 16.01.2020 21:20*

*Edited by author 16.01.2020 21:20*