Facing problem when used double instead of int

Problem : CodeChef: Practical coding for everyone
solution-1 : CodeChef: Practical coding for everyone
solution-2 : CodeChef: Practical coding for everyone

The above problem is a simple one. In the first solution(solution-1), I had avoided decimal number during computation, and it was accepted but while in solution-2, I had used double considering decimal number, but it was not accepted.
Please help me to figure out where I am committing mistake in second approach so that I can use double in the future problem.

Thanks!

Floating point is inherently inaccurate - just use ints if ints will work.

1 Like

@ssjgz Thank you!

1 Like

">