Code didnt pass last test case
@jha.aparna17
You found out the vairiable ans. But you calculating its power in O(n). This is not correct as the power can be of the order of 1e9. Use fast exponentiation to bring down the complexity to O(log(n)).
still didnt pass all test cases
Refer to this code. This should work.
If my answer was able to resolve your query, please mark the doubt as resolved.
still didn’t pass the last test case
Given three numbers a,b,c. Calculate (a^b)mod c. Input Format Single line containing three integers a,b,c separated by space. Constraints 1<=a,b,c<=100000 Output Format Print (a^b)mod c. Sample Input 2 2 3 Sample Output 1 Explanation (2^2)mod 3=4 mod 3 = 1
@jha.aparna17
Set ll to long long in place of unsigned int and it will work.
If my answer was able to resolve your query, please mark the doubt as resolved.
now its giving compilation error
@jha.aparna17
It shouldnt. I have made the changes.
Try it out once. Its working absolutely fine.
If my answer was able to resolve your query, please mark the doubt as resolved.
it got accepted thanks