|
|
вернуться в форумIf you have trouble on test#8 or #48 All the trouble are caused by precision. The first submittion includes the code: angle_ACB = math.acos((x1*x2+y1*y2+z1*z2) / (len_CA*len_CB)) Then I got RE#8 in python, WA#8 in C++. Next I change the code to: angle_ACB = math.acos(0.5*(CA_sqr + CB_sqr - len_AB**2) / (len_CA*len_CB)) in python angle_ACB = acos(0.5* (CA_sqr + CB_sqr - sqr(len_AB))/(len_CA*len_CB)) in C++ Then I got RE#48 in python, WA#48 in C++. So I am sure the trouble is caused by the precision because of the function sqrt()! Sometimes, the cos(angle_ACB) is smaller than -1. Then the problem occurred by using acos(x) if x<-1. You need to handle this situation. |
|
|