您的位置:首页 > 运维架构

(HDU)1053 Entropy (哈夫曼树)

2013-09-16 19:33 302 查看
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1053

#include

#include

#include

#include

using namespace std;

struct node

{

    int
key;

    int f;

    int
lson,rson;

    bool
operator < (const node x)const

    {

   
    return
x.key<key;

    }

};

node father;

node g[3100];

int sum=0;

void fuc(node x,int cnt);

int main()

{

    char
str[1100];

   
while(scanf("%s",str)!=EOF)

    {

   
    sum=0;

   
   
priority_queue p;

   
    int
len=strlen(str);

   
   
if(len==3&&str[0]=='E'&&str[1]=='N'&&str[2]=='D')

   
    {

   
   
    break;

   
    }

   
    int
ii=0;

   
    for(int
i=0;i

   
    {

   
   
    int
cnt=1;

   
   
    char
c;

   
   
   
if(str[i]!='#')

   
   
    {

   
   
   
   
c=str[i];

   
   
   
   
str[i]='#';

   
   
   
    for(int
j=i+1;j

   
   
   
    {

   
   
   
   
   
if(str[j]==c)

   
   
   
   
    {

   
   
   
   
   
    cnt++;

   
   
   
   
   
   
str[j]='#';

   
   
  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: