C.cpp 716 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. map<char, int> M;
  4. void fill() {
  5. M['H'] = 1;
  6. M['C'] = 12;
  7. M['N'] = 14;
  8. M['O'] = 16;
  9. M['F'] = 19;
  10. M['P'] = 31;
  11. M['S'] = 32;
  12. M['K'] = 39;
  13. }
  14. int main() {
  15. fill();
  16. int T;
  17. cin >> T;
  18. while (T--) {
  19. string str;
  20. cin >> str;
  21. int tot = 0;
  22. for (size_t i = 0; i < str.length(); i++) {
  23. if (isalpha(str[i])) {
  24. if (i == str.length() - 1 || isalpha(str[i + 1])) {
  25. tot += M[str[i]];
  26. } else {
  27. tot += M[str[i]] * (str[i + 1] - '0');
  28. }
  29. }
  30. }
  31. cout << tot << endl;
  32. }
  33. return 0;
  34. }