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

Обсуждение задачи 1438. Time Limit Exceeded

Give me answer for my question. Please!
Послано {AESC USU} Evgeny Kurpilyanskij 13 фев 2007 08:00
if (a == b*q+p) and (0 <= p < |b|) then
{
  q == a / b
  p == a % b
}

is it TRUE?

Edited by author 13.02.2007 14:34
Re: Give me answer for my question. Please!
Послано [SPbSU ITMO] WiNGeR 13 фев 2007 17:46
a % b == p - correct
a / b is standard (just a / b in your programming language)
Re: Give me answer for my question. Please!
Послано {AESC USU} Evgeny Kurpilyanskij 13 фев 2007 18:57
To WiNGeR:
I should use SIGHNED INT32 or UNSIGHNED INT32

P.S. Sorry for bad English.

Edited by author 13.02.2007 18:57
Re: Give me answer for my question. Please!
Послано [SPbSU ITMO] WiNGeR 13 фев 2007 23:39
SIGNED INT32
Re: Give me answer for my question. Please!
Послано AterLux 11 сен 2010 02:30
0 <= |p| < |b| correct
because if p = a - b * q, and q = a / b, you can see, p should be negative for negative a.
But sample test provides positive remainder. I think this is mistake in tests.
Use this
p = a % b;
if (p < 0) p += abs(b);

Edited by author 11.09.2010 05:45