diff options
| author | Paul Jungeblut <s_jungeb@i08pc57.atis-stud.uni-karlsruhe.de> | 2014-11-22 11:46:50 +0100 |
|---|---|---|
| committer | Paul Jungeblut <s_jungeb@i08pc57.atis-stud.uni-karlsruhe.de> | 2014-11-22 11:46:50 +0100 |
| commit | ca740ed7caeca4deb09a2fc7912f599555442e15 (patch) | |
| tree | ae25a2d25643067731eafaf16ee9ddf44f008d4e /math/modExp.cpp | |
| parent | fa83b8c841073b462840260b54593767e597f543 (diff) | |
bisschen LGS
Diffstat (limited to 'math/modExp.cpp')
| -rw-r--r-- | math/modExp.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/math/modExp.cpp b/math/modExp.cpp new file mode 100644 index 0000000..f738268 --- /dev/null +++ b/math/modExp.cpp @@ -0,0 +1,7 @@ +ll modPow(ll b, ll e, ll p) { + if (e == 0) return 1; + if (e == 1) return b; + ll half = modPow(b, e / 2, p), res = (half * half) % p; + if (e & 1) res *= b; res %= p; + return res; +}
\ No newline at end of file |
