diff options
author | Ta180m | 2020-04-10 17:39:17 -0500 |
---|---|---|
committer | Ta180m | 2020-04-10 17:39:17 -0500 |
commit | 193535b92d35ff6f30ab8e08e435ca2d65bc5cf9 (patch) | |
tree | a9f738dfa93b286859dc55078843c19db36a1c81 /Math | |
parent | 174f6421541ab2b0443543dfb4df533f48c2943d (diff) |
Added some number theory stuff
Diffstat (limited to 'Math')
-rw-r--r-- | Math/numtheory.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Math/numtheory.cpp b/Math/numtheory.cpp new file mode 100644 index 0000000..a950f57 --- /dev/null +++ b/Math/numtheory.cpp @@ -0,0 +1,13 @@ +constexpr ll MOD = 1e9+7; + +int pow(int base, int exp) { + int res = 1; + while (exp) { + if (exp & 1) res = ((ll)base * res) % MOD; + exp >>= 1; + base = ((ll)base * base) % MOD; + } + return res; +} + +int inv(int x) { return pow(x, MOD - 2); } |