就是不明白为啥gets就是不对,后台读数据有问题,嗯,一定是
#include <bits/stdc++.h>
using namespace std;
int pp[140];
char str[140];
int main()
{
while(~scanf("%s",str))
{
getchar();
memset(pp, 0, sizeof(pp));
int sum = strlen(str)*8;
priority_queue<int, vector<int>, greater<int> >Q;
for(int i = 0; str[i] != '\0'; i++)
{
pp[str[i]]++;
}
for(int i = 0; i < 140; i++)
{
if(pp[i])
Q.push(pp[i]);
}
int num = 0;
while(!Q.empty())
{
int ans = Q.top();
Q.pop();
if(!Q.empty())
{
int tmp = Q.top();
Q.pop();
ans += tmp;
num += ans;
Q.push(ans);
}
}
printf("%d %d %.1f\n", sum, num, (1.0*sum)/num);
}
return 0;
}