Getting WA at this problem: https://www.codechef.com/problems/MATHCHEF

Any hints or test cases?
Here’s my solution: CodeChef: Practical coding for everyone