NWU_ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 #include <bits/stdc++.h>
 2 #define _xx ios_base::sync_with_stdio(0);cin.tie(0);
 3 using namespace std;
 4 typedef long long ll;
 5 int main()
 6 {
 7     int a[27];
 8     memset(a, 0, sizeof(a));
 9     string s;
10     cin >> s;
11     for(int i = 0; i < s.size(); i++)
12     {
13         if(s[i] > 'Z') a[s[i] - 'a']++;
14         else a[s[i] - 'A']++;
15     }
16     ll ans = 0;
17     sort(a, a + 27);
18     for(int i = 1; i <= 26; i++)
19         ans += i*a[i];
20     cout << ans << endl;
21     return 0;
22 }
View Code

 

posted on 2017-04-04 11:48  NWU_ACM  阅读(129)  评论(0编辑  收藏  举报