文章
11
粉丝
216
获赞
4
访问
103.0k
#include<iostream>
#include<queue>
#include<string>
#include<stdio.h>
#include<cstring>
using namespace std;
int a[30];
int main()
{
int len;
int ans;
int tmp;
double cpsn;
string s;
while (cin >> s)
{
ans = 0;
if (s == "END") break;
len = s.size();
memset(a, 0, sizeof(a));
for (int i = 0; i < len; i++)
{
if (s[i] == '_')
{
a[27]++;
}else
{
a[s[i] - 'A']++;
}
}
priority_queue<int, vector<int>, greater<int> > q;
for (int i = 0; i <= 27; i++)
{
if (a[i] > 0)
q.push(a[i]);
}
if (q.size() == 1) ans = q.top(); //考虑单一字符的字符串的特殊情况处理
while (q.size() > 1)
{
tmp = q.top();
q.pop();
tmp += q.top()...
登录后发布评论
暂无评论,来抢沙发