#include <iostream> #include <queue> #include <vector> #include <string> #include <algorithm> using namespace std; int getBeautyDeg(string& ss){ vector<int> count(26); for(char c: ss){ count[c - 'a']++; } sort(count.begin(), count.end(), [](int& a, int& b){ return a > b; }); int score = 26, sum = 0; for(int cnt: count){ sum += cnt * score; score--; } return sum; } int main() { int n; while(cin >> n){ string str; for(int i = 0; i < n; ++i){ cin >> str; int s = getBeautyDeg(str); str.clear(); cout << s << endl; } } return 0; } // 64 位输出请用 printf("%lld")