Facing problem when used double instead of int

Problem : Contest Page | CodeChef
solution-1 : Solution: 51944622 | CodeChef
solution-2 : Solution: 51946315 | CodeChef

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

">