diff options
Diffstat (limited to 'content/math/discreteNthRoot.cpp')
| -rw-r--r-- | content/math/discreteNthRoot.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/content/math/discreteNthRoot.cpp b/content/math/discreteNthRoot.cpp new file mode 100644 index 0000000..403cb3b --- /dev/null +++ b/content/math/discreteNthRoot.cpp @@ -0,0 +1,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); +} |
