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

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

If you have trouble on test#8 or #48
Послано Rotter Tarmination 27 ноя 2025 21:55
All the trouble are caused by precision.

The first submittion includes the code:
angle_ACB = math.acos((x1*x2+y1*y2+z1*z2) / (len_CA*len_CB))
Then I got RE#8 in python, WA#8 in C++.

Next I change the code to:
angle_ACB = math.acos(0.5*(CA_sqr + CB_sqr - len_AB**2) / (len_CA*len_CB)) in python
angle_ACB = acos(0.5* (CA_sqr + CB_sqr - sqr(len_AB))/(len_CA*len_CB)) in C++
Then I got RE#48 in python, WA#48 in C++.

So I am sure the trouble is caused by the precision because of the function sqrt()!
Sometimes, the cos(angle_ACB) is smaller than -1.
Then the problem occurred by using acos(x) if x<-1.
You need to handle this situation.