Help me in solving SPCHEF problem

My issue

I’m not understanding the power part of the question. How it is calculated by the even/odd powers in if conditional statement.

My code





Problem Link: SPCHEF Problem - CodeChef