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

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

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.
Gheorghe Stefan No shit! [1] // Задача 1023. Пуговицы 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.
>
cmc_hope Re: No shit! // Задача 1023. Пуговицы 14 май 2004 11:45
what will you do when K is a prime number?
For example,k=3.
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.
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
...
xu xiao tao The answer is incorrect! [1] // Задача 1023. Пуговицы 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?
Alexander Prudaev Re: The answer is incorrect! // Задача 1023. Пуговицы 29 ноя 2005 22:32
is not. trunc(sqrt(k)) - rigth limit
yuwei I don't think it can get AC! Here's mine // Задача 1023. Пуговицы 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.