Advertisement
anechka_ne_plach

Untitled

Nov 6th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <cstring>
  2.  
  3. constexpr int hashi(const char *s, int p, int mod, int index) {
  4.     return index == std::strlen(s) ? 1 : index + 1 == std::strlen(s) ? s[std::strlen(s) - 1] : (p * hashi(s, p, mod, index + 1) % mod);
  5. }
  6.  
  7. constexpr int hash(const char *s, int p, int mod, int index = 0) {
  8.     return hashi(s, p, mod, 0);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement