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

Please tell me why my code got WA!
Posted by Big Guava 8 Mar 2002 12:23
It's very simple,isn't it?

var
    i,k:integer;
begin
    readln(K);
    for i:=3 to round(sqrt(k)) do if k mod i=0 then begin k:=i; break end;
    writeln(k-1);
end.
I got AC now,but why?
Posted by Big Guava 8 Mar 2002 16:24
> It's very simple,isn't it?
>
> var
>     i,k:integer;
> begin
>     readln(K);
>     for i:=3 to round(sqrt(k)) do if k mod i=0 then begin k:=i; break end;
>     writeln(k-1);
> end.

if I modify it to : for i:=3 to round(sqrt(k))+100, it is AC.
if modify to round()+1 or +2 , WA
Finally, I use : for i:=3 to 10000  :(
simple...
Posted by I have answers to all your questions :) 8 Mar 2002 23:35
test ur program with k = 26 and u'll know why :)
Re: simple...
Posted by Big Guava 9 Mar 2002 10:53
I got it ! Thank you ! ^_^
> test ur program with k = 26 and u'll know why :)