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

Обсуждение задачи 1679. Башня дядюшки Скруджа

Vedernikoff Sergey (HSE: EconomicsForever!) Re: Float number precision kills, use integer calculations will do [2] // Задача 1679. Башня дядюшки Скруджа 21 фев 2009 23:27
A got AC using real numbers with EPS = 1e-8, so precision is not major matter here...
i think it is safe to rotate point 1 90 degrees 4 times and check if it is possible to align the rotated point 1 with point 2 to form an edge of the square. rotated point1 will also have integer coordinates.
Thanks, Neal Zane!
Your idea is fruitful indeed. I've already gave up to overcome test#24, where float calculations seem to be very sensitive to precesion. And tan/atan along with sqrt gave me error of 10^-8. Now totally integer solution is concise and fast!
Thanks for idea. Simple and beautiful. My previous AC solution was more difficult.
I have tried this way. When I used the formula 2*(y0*x1 - y1*x0)^2 ? R^2*((x1 - x0)^2 + (y1 - y0)^2) (with 3 x <- -y, y <- x) (with long long on right side) has received WA 3.
My previous right solution with use of floats has no more lines and operations. Therefore I believe that geometrical problems to solve in the habitual ways (via floats with epsilon) more preferably.
It is necessary to use a "wheel", instead of to invent something new when good average speed of the decision of a problem is necessary.
I was very surprised, when after WA1 and WA 2 my solution was accepted :)

Pay attention to the situation, when points becomes the same.
Oleg Strekalovsky [Vologda SPU] писал(a) 21 июня 2010 04:12
Pay attention to the situation, when points becomes the same.

Thanks! Very useful hint!