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

Why it doesn't work?
Posted by Pier Paolo Guillen Hernandez 30 Jun 2002 06:53
Var
  i,k,t: longint;

Begin
    readln (input,k);
    t:= round(sqrt(k)) +1;
    for i:= 3 to t do
        if (k mod i) = 0 then break;
    If i<>t then writeln (output, i-1)
            else begin
                 if ((k mod 2) = 0) then k:= k shr 1;
                 writeln (output, k-1);
                 end;
End.
Checa el caso para k = 4 ;) (-)
Posted by Miguel Angel 30 Jun 2002 08:20
> Var
>   i,k,t: longint;
>
> Begin
>     readln (input,k);
>     t:= round(sqrt(k)) +1;
>     for i:= 3 to t do
>         if (k mod i) = 0 then break;
>     If i<>t then writeln (output, i-1)
>             else begin
>                  if ((k mod 2) = 0) then k:= k shr 1;
>                  writeln (output, k-1);
>                  end;
> End.
>
Gracias! (Thanks!)
Posted by Pier Paolo Guillen Hernandez 1 Jul 2002 06:47
(I had already checked that case but then I change a little the code
and forgot about it.
 I solve that problem by changing
t:= round(sqrt(k)) +1; to
t:= round(sqrt(k)) +3;
 bt I still get "wrong answer". Any other ideas?
  By the way, &#1111;from which state are you?)


 Ya hab&#1085;a checado ese caso pero lo cambie un poco el c&#1091;digo y no lo
volv&#1085; a revisar.
 Arregle ese problema cambiando
t:= round(sqrt(k)) +1; por
t:= round(sqrt(k)) +3;
 pero a&#1098;n asi no me lo acepta. &#1111;Tienes otra idea?
  A prop&#1091;sito, &#1111;de que &#1081;stado eres?
Well maybe...(+)
Posted by Miguel Angel 1 Jul 2002 07:11
I think your solution is OK, but you need to add the special case of
k = 4, (with an if). And i'm from Mty, i'm studying at ITESM. Where
are you?. Good Luck.
mail: miguelangelhdz@hotmail.com