(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]='#';
#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]='#';
相关文章推荐
- HDU 2552 三足鼎立
- HDU 2088 Box of Bricks
- HDU 1555 How many days?
- HDU 1234 开门人和关门人
- HDU:2046骨牌铺方格 解题报告
- HDU: 2015 偶数求和
- HDU:2067 小兔的棋盘
- hdu 1466 计算直线的交点数 第四专…
- HDU 1029 Ignatius and the Prince…
- HDU 1102 Constructing Roads
- HDU 2255 奔小康赚大钱(KM算法)
- hdu&nbsp;4081&nbsp;最小生成树变形
- hdu 1858 Max Partial Value I(DP…
- hdu 3213 GCC
- hdu 1759 Function Run Fun
- (HDU)1213 How Many Tables
- hdu 1854 Q-Sequence
- HDU 2547 无剑无我
- HDU 2078 复习时间
- HDU 1491 Octorber 21st