Problem with code

used same approach but wrong answer.
problem:


my solution:
https://www.codechef.com/viewsolution/27979463
AC solution:
https://www.codechef.com/viewsolution/27917523

Hi

you are using types with not enought precision to represent results.
I changed Init value of accumulate to (int64_t). result of operation will then also be 64 bit integer.
Also i change datatype for sum from float to double to have more significant bits available.
Afterwards the code gets accepted.
https://www.codechef.com/viewsolution/27979699

1 Like