就是统计下字母个数排个序,算是贪心吧,,
#include <bits/stdc++.h>
using namespace std;
#define ls st<<1
#define rs st<<1|1
#define LL long long
const int MAXN= (int) 26;
int arr[MAXN];
bool check(char ch) {
return ch>='A'&&ch<='Z';
}
int main() {
ios::sync_with_stdio(false);
string s;
cin >> s;
for (int i = 0; i < (int)s.size(); ++i) {
if(check(s[i]))
arr[s[i]-'A']++;
else
arr[s[i]-'a']++;
}
int k = 26, sum = 0;
sort(arr, arr+26, greater<int>());
for (int i = 0; i < 26; ++i) {
if (arr[i]) {
sum +=arr[i]*k;
k--;
}
}
cout << sum << endl;
return 0;
}