WA- where does floating point error occur?

Правка en1, от vsanjay_nitdgp, 2016-02-10 20:19:46

Recently,I solved a problem.

This is one of my step in my solution:

ans=ans-(2*b*c[n]);

ans is double variable,b is integer,c[n] is double; my answer was judged wrong.

when i changed the step to

double p=2*b*c[i];
ans=ans-p;

My solution got ACCEPTED.Could anyone say,why this occur,so that it would be very helpful for future problems of this kind.

Thanks.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский vsanjay_nitdgp 2016-02-10 20:19:46 464 Initial revision (published)