problem in calculating modular exponentiation

I tried to solve a problem based on modular exponentiation:

I saw a solution of a different programmer

Can anyone explain why this solution is correct. And also add editorial to this problem.

You don’t need modular exponentiation for this problem due to the constraints (1<=Y<=10).

However,You can read about it here.

Here is the working

( with modular exponentiation.

However, even a [naive approach]( gives AC in $0.00s$.

Hope this helps.

As sarvagya3943 said. You don’t need any modular exponentiation. Also you don’t need long long integers. This very simple solution will suffice. This works on a*b%m=((a%m)*b)%m. I can’t write the editorial as my Karma isn’t that good. Please upvote if this helped you.

1 Like