ABC Conjecture 3 Practice Coding Problem - CodeChef

my solution : Status: Wrong Answer

What will be correct approach ?