|
|
back to boardFloat number precision kills, use integer calculations will do 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 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 Thanks for idea. Simple and beautiful. My previous AC solution was more difficult. Re: Float number precision kills, use integer calculations will do 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 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 Pay attention to the situation, when points becomes the same. Thanks! Very useful hint! |
|
|