fork download
  1. #include <iostream> /* C++ iostream C++98/11 */
  2. #include <string> /* C++ strings C++98/11 */
  3. // #include <boost/regex.hpp> /* RegEx Boost */
  4. #include <boost/algorithm/string/replace.hpp>
  5.  
  6. using namespace std;
  7.  
  8. static uint32_t
  9. Fnv1(const std::string& text)
  10. {
  11. constexpr uint32_t FNV_OFFSET = 0x811c9dc5;
  12. constexpr uint32_t FNV_PRIME = 16777619;
  13.  
  14. uint32_t hash = FNV_OFFSET;
  15. for (const char letter : text) {
  16. hash *= FNV_PRIME;
  17. hash ^= letter;
  18. }
  19.  
  20. return hash;
  21. }
  22.  
  23. int main() {
  24.  
  25. string obj {"1999#"};
  26. uint32_t hash = Fnv1(obj);
  27.  
  28.  
  29.  
  30. cout<<hash<<endl;
  31. cout<<hash%64<<endl;
  32. }
  33.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
1085289608
8