summaryrefslogtreecommitdiff
path: root/content/math/discreteNthRoot.cpp
blob: 403cb3ba7325567e59962f9eae4da22a53a2ce5b (plain)
1
2
3
4
5
ll root(ll a, ll b, ll m) { // a > 0!
	ll g = findPrimitive(m);
	ll c = dlog(powMod(g, a, m), b, m);
	return c < 0 ? -1 : powMod(g, c, m);
}