What is wrong in the code
your approach looks wrong. What are you trying to do. Just multiplying the mid to ans? Can you be more descriptive so I can help you.
i am multiplying because i want to make the mid to mid^k then i m applying binary search
Ok so first mistake is, that you are not initialising ans back to 1 after each try. before the loop ans should be set to 1.
thanks for correcting code