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

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

Float number precision kills, use integer calculations will do
Послано Neal Zane 21 фев 2009 15:46
Re: Float number precision kills, use integer calculations will do
Послано Vedernikoff Sergey (HSE: EconomicsForever!) 21 фев 2009 23:27
A got AC using real numbers with EPS = 1e-8, so precision is not major matter here...
Re: Float number precision kills, use integer calculations will do
Послано Neal Zane 22 фев 2009 08:18
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.
Re: Float number precision kills, use integer calculations will do
Послано strider 23 фев 2009 10:31
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!
Re: Float number precision kills, use integer calculations will do
Послано Alex Tolstov (Vologda STU) 3 окт 2009 18:03
Thanks for idea. Simple and beautiful. My previous AC solution was more difficult.
Re: Float number precision kills, use integer calculations will do
Послано dd (mp dpt USTU) 6 ноя 2009 05:00
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.
Re: Float number precision kills, use integer calculations will do
Послано Oleg Strekalovsky [Vologda SPU] 21 июн 2010 04:12
I was very surprised, when after WA1 and WA 2 my solution was accepted :)

Pay attention to the situation, when points becomes the same.
Re: Float number precision kills, use integer calculations will do
Послано KALO 27 янв 2011 02:09
Oleg Strekalovsky [Vologda SPU] писал(a) 21 июня 2010 04:12
Pay attention to the situation, when points becomes the same.

Thanks! Very useful hint!