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

Обсуждение задачи 1075. Нитка в пространстве

Why WA on #9
Послано MultiThread 6 окт 2006 08:55
I got WA on test#9. Could somebody kindly give me some tests? Thanks a lot. :-)
Re: Why WA on #9
Послано Uran 6 апр 2007 18:38
I have same thing too.
Re: Why WA on #9
Послано Iskren Ivov Chernev 7 окт 2007 20:13
I had WA#9 too. I reviewed my code and tuned thing for precision. Then I got AC.
What can you do for precision:
  -when possible use square of distance (avoid sqrt ())
  --when calculation cos(x) == A^2 + B^2 - C^2 / 2 * A * B you can do something like sqrt (4 * A ^ 2 * B ^ 2) and therefore minimize the number of calls to sqrt
  -calculate sin(x) from cos(x) -- sqrt (1. - cos(x) ^ 2) -- sqrt is better than acos/asin.
  -check for (un)equality using epsilon (mine is 1e-7).
  -call asin/acos after the check (if (a > 1) a = 1; if (a < -1) a = -1)
  -optimize the amount of calculation as much as possible at any step. Avoid calling (sqrt (x)) ^ 2
  -GOOD LUCK

P.S. After additional testing I realized that the 2 most important things are (my problem passed only with this modifications)
-- check if the circle interferes with AB using cos theorem:
if (AC ^ 2 + EPS > AB ^ 2 + BC ^ 2
  ||  BC ^ 2 + EPS > AB ^ 2 + AC ^ 2)
--use sqrt (4 * A ^ 2 * B ^ 2) when calculating a cos of an angle in a triangle using the square of the lengths of its edges.
--calculate sin(x) given cos(x) (without acos) -- sqrt (1 - cos (x) ^ 2)

Edited by author 07.10.2007 20:28
Re: Why WA on #9
Послано Sean38 22 дек 2007 21:36
In fact,in #9,A and B are(is?)the same point(s).

Sorry for my poor English.
Re: Why WA on #9
Послано Dmitry "Logam" Kobelev [TSOGU] 28 авг 2008 15:59
Yes, they are the same. It's only one place where you need epsilon. All the rest computations could be done with EPS = 0.