Problem link : CHMOD

My code : CHMOD

I know that this solution won’t pass the time limit but I can’t understand the reason for WA. Please help.

Although it will give TLE. But, there is something wrong in your program. You are not using modulo well.

Instead of this satement

z = z * a[p];

Use this

z = z * a[p] % r;

Hope it helps.

1 Like