MCPcopy Create free account
hub / github.com/atcoder/ac-library / pow_mod_constexpr

Function pow_mod_constexpr

atcoder/internal_math.hpp:66–77  ·  view source on GitHub ↗

@param n `0 <= n` @param m `1 <= m` @return `(x ** n) % m`

Source from the content-addressed store, hash-verified

64// @param m `1 <= m`
65// @return `(x ** n) % m`
66constexpr long long pow_mod_constexpr(long long x, long long n, int m) {
67 if (m == 1) return 0;
68 unsigned int _m = (unsigned int)(m);
69 unsigned long long r = 1;
70 unsigned long long y = safe_mod(x, m);
71 while (n) {
72 if (n & 1) r = (r * y) % _m;
73 y = (y * y) % _m;
74 n >>= 1;
75 }
76 return r;
77}
78
79// Reference:
80// M. Forisek and J. Jancina,

Callers 4

is_primitive_rootFunction · 0.85
is_primitive_rootFunction · 0.85
is_prime_constexprFunction · 0.85
primitive_root_constexprFunction · 0.85

Calls 1

safe_modFunction · 0.85

Tested by 1

is_primitive_rootFunction · 0.68