51nod-1182

#include <iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int A[26];
int main(void)
{
	string s;
	cin>>s;
	for(size_t i=0;i<s.size();i++)
	{
		if(islower(s[i]))
		{
			A[s[i]-'a']++;
		}
		else
		{
			A[s[i]-'A']++;
		}
	}
	sort(A,A+26);
	int sum=0;
	for(int i=0;i<26;i++)
	{
		sum+=A[i]*(i+1);
	}
	cout<<sum;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/hj13547816754/article/details/79859894
今日推荐