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

Why i got WA?Can anybody tell me? Thanks!
Posted by TaoZhang 10 Sep 2002 19:29
Here is my program
var
 n,k,i,time:longint;

begin
 readln(n,k);
 if k=1 then writeln(n-1)
  else
   begin
    i:=0;time:=0;n:=n-1;
    while n>0 do
     begin
      if i<k then i:=i+1;
      n:=n-i;time:=time+1;
     end;
    writeln(time);
   end;
end.
Re: Why i got WA?Can anybody tell me? Thanks!
Posted by Vladimir Milenov Vasilev 16 Sep 2002 04:37
> Here is my program
> var
>  n,k,i,time:longint;
>
> begin
>  readln(n,k);
>  if k=1 then writeln(n-1)
>   else
>    begin
>     i:=0;time:=0;n:=n-1;
>     while n>0 do
>      begin
>(***)  if i<k then i:=i+1;
>       n:=n-i;time:=time+1;
>      end;
>     writeln(time);
>    end;
> end.

Have a look at the iteraton..as I understand i is the number of used
cables... But on each iteration you should not add only one cable
(***) but as much as possible, I mean if you have used i cables by
now, next time you could use 2*i cables, if you have so much, NOT
i:=i+1!
Sample input:
12 6
Sample output:
4

1 sec.   1-2
2 sec.   1-3, 2-4
3 sec.   1-5,2-6,3-7,4-8
4 sec.   1-9,2-10,3-11,4-12
Bye!
and Have a luck :)
Re: Why i got WA?Can anybody tell me? Thanks!
Posted by Bahodir | {TUIT} | 5 Dec 2014 20:33
thanks ...!!!