|
|
вернуться в форумWhy it doesn't work? 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 ;) (-) > 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!) (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, їfrom which state are you?) Ya habнa checado ese caso pero lo cambie un poco el cуdigo y no lo volvн a revisar. Arregle ese problema cambiando t:= round(sqrt(k)) +1; por t:= round(sqrt(k)) +3; pero aъn asi no me lo acepta. їTienes otra idea? A propуsito, їde que йstado eres? Well maybe...(+) 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 |
|
|