pow is a floating point function, not an integer function, and doubles can not always store integers exactly. It is quite possible that it returns xxx.9999999 rather than an exact integer, and that will round down to the wrong value. You will also get in trouble comparing doubles for the same reason.
On Sep 14, 5:19 pm, vaibhav <[email protected]> wrote: > In this problem I used the pow function (present in math.h library of > c++).It got accepted for small test case but gave me wrong answer for > the large test case.When I later changed the program and used the > iterative method and calculated powers iteartively rather then using > the inbuilt pow function the answer was correct.when I compared the > files the difference between the answers varied from 1-20. I couldnt > qualify only due to this error. > > Can someone please through some light on this working of pow function. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-code?hl=en -~----------~----~----~----~------~----~------~--~---
