#include #include using namespace std; map init() { map defineKey; char key = 'A'; for (int i = 0; i < 26; i++) { defineKey.insert(make_pair(key, i + 1)); key += 1; } return defineKey; } int main() { map mpKey = init(); char keys[256] = {'\0'}; while (cin.getline(keys, 256)) { if (keys[0] == '#') { break; } int val = 0; int result = 0; for (int i = 0; keys[i] != '\0'; i++) { if (keys[i] < 'A' || keys[i] > 'Z') { continue; } map::iterator iter = mpKey.find(keys[i]); if (iter != mpKey.end()) { val = iter->second; } // cout << "val - " << val << endl; result += ((i+1)*val); } cout << result << endl; memset(keys, 0, 256); } return 0; }