KAN13G - Problem

I got the program to work in ideone using C++(4.8.1) . However i am getting a wrong answer problem . Apparently the problem would be in precision since my code uses float extensively. How to avoid problems with float?

//