NMNMX - Editorial

What is the use of Fermat little theorem here ? could it be done just by using modular exponentiation ?

Thanks bro.

1 Like

Since 1=a0 for any a, we could say that a^x=a^x(modp−1)(modp).

I am trying but not able to figure out how the statement comes out of Fermat’s little theorem and the fact that a raised to 0 becomes 1.

Can someone please elaborate?

Try 3-tower coloring question of hackerrank and read its editorial.

1 Like

@vijju123: Thank you. That explanation was very helpful.

1 Like

For people having difficulty in understanding why we mod the power with (m-1) :

This is a very neat proof.

Please upvote if I helped so that I can qualify to upvote others. :))

1 Like

@ritam777
During the contest, I was trying to do this but could not. Thank you so much as I now understand it :))

Sorry I am not qualifed to upvote otherwise I would have.

Why do subset or subsequence doesn’t matter?