ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1679. Scrooge's Tower

Float number precision kills, use integer calculations will do
Posted by Neal Zane 21 Feb 2009 15:46
Re: Float number precision kills, use integer calculations will do
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
Posted by Neal Zane 22 Feb 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
Posted by strider 23 Feb 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
Posted by Alex Tolstov (Vologda STU) 3 Oct 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
Posted by dd (mp dpt USTU) 6 Nov 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
Posted by Oleg Strekalovsky [Vologda SPU] 21 Jun 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
Posted by KALO 27 Jan 2011 02:09
Oleg Strekalovsky [Vologda SPU] wrote 21 June 2010 04:12
Pay attention to the situation, when points becomes the same.

Thanks! Very useful hint!