MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / mod_pow

Function mod_pow

code/mathematics/mod_pow.cpp:2–7  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1template <class T>
2T mod_pow(T b, T e, T m) {
3 T res = T(1);
4 while (e) {
5 if (e & T(1)) res = smod(res * b, m);
6 b = smod(b * b, m), e >>= T(1); }
7 return res; }
8// vim: cc=60 ts=2 sts=2 sw=2:

Callers 4

testFunction · 0.85
legFunction · 0.85
tonelli_shanksFunction · 0.85
is_probable_primeFunction · 0.85

Calls 1

smodFunction · 0.85

Tested by 1

testFunction · 0.68