|
|
back to boardWA#1 Why? I pass the given tests correctly. BTW, the problem can have several answers, :S Re: WA#1 Posted by Al.Cash 25 Oct 2008 17:48 I had WA#1, then WA#22. Can somebody help me? I think there are problems with precision. Re: WA#1 Wow, I also have WA#22 now. BTW, my WA#1 was because I didn't #include <math.h> LOL Re: WA#1 Posted by Al.Cash 25 Oct 2008 18:01 AC now))) Using epsilon in some more places helped me a lot! Re: WA#1 Posted by Chiffa 25 Oct 2008 18:02 According formule S=sqrt(p*(p-a)*(p-b)*(p-c)) => the problem has 3 different answers. Re: WA#1 Posted by Al.Cash 25 Oct 2008 18:08 No! Sample #2 has only one answer. Re: WA#1 Posted by svr 26 Oct 2008 09:52 Yes!Agree.Impossible get Ac without eps. Epsilon Please, who can explain me why epsilon is needed in problems which contain real numbers, and where should I use it in this problem? I got WA#22, and can't understand my mistake. Re: Epsilon Posted by svr 27 Oct 2008 09:44 There are many trick with epsilon. For example. Let eps=1e-10 and some geometrical value d calculated as -1.e-11. We reject this calculation because d must be >=0 and make mistake lossing d=0. With eps we do it as if (fabs(d)<=eps) d=0 thus accepting negative -1e-11. Re: Epsilon When I used eps=1e-13, I got WA #22, and when I chaged it to 1e-10, I got AC. Here are fragments, where I use eps: ... double d=p*p-2*a*b; if(fabs(d)<eps) ... (d is discriminant of square equation) ... if(t1>a+eps || t2>b+eps) return false; ... (check that t1<=a and t2<=b). I can't understand why I had this situation. Re: Epsilon Maybe the numbers are big, so adding 1e-13 is equal to adding 0. Re: Epsilon eps = 1e-10 thanks! Edited by author 30.07.2011 02:06 Edited by author 30.07.2011 02:06 |
|
|