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 1023. Buttons

Vedensky Kirill Why is this code wrong? [1] // Problem 1023. Buttons 6 Apr 2002 18:45
var k,l : longint;

BEGIN
   Read(k);
   for l := 2 to k-1 do if k mod (l+1) = 0 then
   begin
      Write(l);
      Exit;
   end;
END.
LiangHonghao Re: Why is this code wrong? // Problem 1023. Buttons 7 Apr 2002 15:59
> var k,l : longint;
>
> BEGIN
>    Read(k);
>    for l := 2 to k-1 do if k mod (l+1) = 0 then
>    begin
>       Write(l);
>       Exit;
>    end;
> END.
If you got a wrong answer.
I'll tell you
if you still use 2 to k-1
you will also get a TimeLimitedError.
try 3 to k/2
i got a AC in this way.
REMBER you should carful with 2