I tried to solve a problem based on modular exponentiation:

I saw a solution of a different programmer

https://www.codechef.com/viewsolution/8262422

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

I tried to solve a problem based on modular exponentiation:

I saw a solution of a different programmer

https://www.codechef.com/viewsolution/8262422

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

```
(https://www.codechef.com/viewsolution/9042839) with modular exponentiation.
However, even a [naive approach](https://www.codechef.com/viewsolution/9042859) gives AC in $0.00s$.
Hope this helps.
```

2 Likes

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