This is the solution.Tried all test cases with zeros.Still getting WA
try some more testcases if you cannot think of more testcases i would recommend trying some testcases
from http://spojtoolkit.com/ match your solution answers on the testcases provided.
spoj solutions are not public, paste ideone link