|
|
вернуться в форумWhy? I pass the given tests correctly. BTW, the problem can have several answers, :S I had WA#1, then WA#22. Can somebody help me? I think there are problems with precision. Wow, I also have WA#22 now. BTW, my WA#1 was because I didn't #include <math.h> LOL AC now))) Using epsilon in some more places helped me a lot! Yes!Agree.Impossible get Ac without eps. 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. 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. 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. Maybe the numbers are big, so adding 1e-13 is equal to adding 0. eps = 1e-10 thanks! Edited by author 30.07.2011 02:06 Edited by author 30.07.2011 02:06 According formule S=sqrt(p*(p-a)*(p-b)*(p-c)) => the problem has 3 different answers. No! Sample #2 has only one answer. |
|
|