码迷,mamicode.com
首页 > 其他好文 > 详细

完美字符串

时间:2017-04-04 12:42:13      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:define   str   ace   size   end   技术   hid   typedef   namespace   

技术分享
 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

 

完美字符串

标签:define   str   ace   size   end   技术   hid   typedef   namespace   

原文地址:http://www.cnblogs.com/NWUACM/p/6664599.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!