Modular Exponential test case error

Hi @rohit267, in this problem you have to find (a^b)mod c, now at line 9 you are doing
double p=pow(a,b); now if a=10000, and b=10000 then overflow will occur as double cant store word as big as 10000^10000 , so you have to take modulus at every stage of multiplication , also this question is not intended to be solved by using stl function you have to make your own function
u can refer this :-

long long binpow(long long a, long long b, long long c) {
    a %= c;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % c;
        a = a * a % c;
        b >>= 1;
    }
    return res;
}

refer this for detailed explanation

In case of any doubt feel free to ask :slight_smile:
mark your doubt as resolved if u got the answer