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

My Solution:You should only find the minimum number l that can be divide by k,if no such number l,write(k-1) else write(l-1)
Posted by Dick162 20 Jan 2003 17:46
program ex;
var
  now,i,l,k:longint;
begin
  readln(k);
  now:=k;
  for i:=3 to trunc(sqrt(100000000)) do
   if k mod i=0 then begin now:=i; break; end;
  writeln(now-1);
end.
No shit!
Posted by Gheorghe Stefan 28 Jul 2003 23:43
> program ex;
> var
>   now,i,l,k:longint;
> begin
>   readln(k);
>   now:=k;
>   for i:=3 to trunc(sqrt(100000000)) do
>    if k mod i=0 then begin now:=i; break; end;
>   writeln(now-1);
> end.
>
Re: No shit!
Posted by cmc_hope 14 May 2004 11:45
what will you do when K is a prime number?
For example,k=3.
Re: My Solution:You should only find the minimum number l that can be divide by k,if no such number l,write(k-1) else write(l-1)
Posted by Victor S 14 May 2004 15:43
program ex;
var
now,i,l,k:longint;
begin
readln(k);
now:=k;
for i:=3 to 10000 do {trunc(sqrt(100000000))=10000}
if k mod i=0 then begin now:=i; break; end;
writeln(now-1);
end.
Re: My Solution:You should only find the minimum number l that can be divide by k,if no such number l,write(k-1) else write(l-1)
Posted by Neo 4 Jun 2004 22:33
I have tried.
Itself so thought.
Wrong answer.
Re: My Solution:You should only find the minimum number l that can be divide by k,if no such number l,write(k-1) else write(l-1)
Posted by ss 5 Jul 2004 13:59
I did so at the first time
but got WA
Try this test
1999966
the correct answer is 999982
but the result of your program is 1999965
...
The answer is incorrect!
Posted by xu xiao tao 3 Oct 2004 23:16
In this problem, trunc(sqrt(100000000)) isn't a right limit.
We should use (k div 2)+1 for the high limit,isn't it?
I don't think it can get AC! Here's mine
Posted by yuwei 27 Oct 2004 18:11
var
  n,l,i:longint;
begin
  readln(n);
  l:=n-1;
  if ((n mod 2)=0) and (n div 2>2) then l:=n div 2-1;
  for i:=2 to trunc(sqrt(n)) do
    if n mod (i+1)=0 then begin
      l:=i;
      break
    end;
  writeln(l)
end.
Re: The answer is incorrect!
Posted by Alexander Prudaev 29 Nov 2005 22:32
is not. trunc(sqrt(k)) - rigth limit