Binary mod

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
211 B
8
Indexable
Never
long long mod_exp(long long x, long long y, long long mod) {
    long long res = 1;
    while(y > 0) {
        if(y & 1) res = res*x % mod;
        y >>= 1;
        x = x*x % mod;
    }
    return res;
}