ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1131. Copying

WA5 What is wrong? help pls.
Posted by Dmitry_Terenichev 7 Mar 2017 19:39
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.
Posted by kolqueqo 16 Jan 2020 21:13
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