Fast Exponentiation [FEXP]

Subtask 3 giving WA*

Problem link → https://www.codechef.com/problems/FEXP

This solution appears to be giving WA, not TLE, for Subtask 3.

Yes, it was WA. My bad. Edited.

1 Like

Hmmm … I have to admit, I’m drawing a blank, here :slight_smile:

The b % mod in long res = power(a%mod,((b%mod)/2))%mod; is wrong, but, assuming the constraints are correct, this shouldn’t make a difference in practice as we’ll always have b \le mod. Can you try it again with just b instead of b % mod?

Edit:

As I suspected - the constraints for the problem are wrong. Compare this solution (AC) vs this solution (RE) - the only difference is that the latter asserts that the constraints stated in the Problem are satisfied. smh

@vijju123 - any chance of getting the Problem description/ testcases updated for this question?

4 Likes

Worked! Thanks :smiley:

1 Like