CodeChef: Practical coding for everyone : link to my solution.
My code passed the 1st testcase successfully, but I am getting RE (SIGFPE) error in the 2nd testcase.
Thanks!
CodeChef: Practical coding for everyone : link to my solution.
My code passed the 1st testcase successfully, but I am getting RE (SIGFPE) error in the 2nd testcase.
Thanks!
SIGFPE signal indicates there was a Floating point error. In this case, division by zero (maybe).
long long ans = floor(a/b);
Now, try figuring out whether this is the reason, using an assert statement.
assert(b != 0);
long long ans = floor(a/b);
Now, if b becomes zero, it will still result in RTE but the signal will be something else.
PS: Think of another easier approach (Parity of N would help).