ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1023. Пуговицы

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)
Послано Dick162 20 янв 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!
Послано Gheorghe Stefan 28 июл 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!
Послано cmc_hope 14 май 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)
Послано Victor S 14 май 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)
Послано Neo 4 июн 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)
Послано ss 5 июл 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!
Послано xu xiao tao 3 окт 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
Послано yuwei 27 окт 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!
Послано Alexander Prudaev 29 ноя 2005 22:32
is not. trunc(sqrt(k)) - rigth limit