Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <cstring>
- constexpr int hash(const char *s, int p, int mod) {
- return std::strlen(s) == 0 ? 1 : std::strlen(s) == 1 ? s[0] : (p * hash(s + 1, p, mod) % mod);
- }
- constexpr int powm(int p, int i, int m) {
- return i == 0 ? 1 : i % 2 == 0 ? (powm((p * p) % m, i / 2, m)) % m : (p * powm(p, i - 1, m)) % m;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement