fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using Hash = unsigned;
  5.  
  6. inline Hash constexpr h_(char const *input) {
  7. return *input ?
  8. static_cast<Hash>(*input) + 33 * h_(input + 1) :
  9. 5381;
  10. }
  11.  
  12. int main()
  13. {
  14. std::string s;
  15. std::cin >> s;
  16. switch (h_(s.c_str()))
  17. {
  18. case h_("first"): {
  19. std::cout << "first" << std::endl;
  20. } break;
  21. case h_("second"): {
  22. std::cout << "second" << std::endl;
  23. } break;
  24. case h_("third"): {
  25. std::cout << "third" << std::endl;
  26. } break;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 15240KB
stdin
SHIRe
stdout
third