POJ 1521 Entropy
来源:互联网 发布:b2b 建站 教程 编辑:程序博客网 时间:2024/05/16 05:11
Huffman树:
题目链接:POJ1521
#include<stdio.h>#include<string.h>#include<queue>using namespace std;int t[100],len;char c[1000];int huffman(){ int a,b,c,sum=0; priority_queue<int,vector<int>,greater<int> >q;//priority_queue<int,vector<int>,greater<int> > q; for(int i=65;i<100;i++) { if(t[i]>0) q.push(t[i]); } while(q.size()>1) { a=q.top();q.pop(); b=q.top();q.pop(); c=a+b; sum+=c; q.push(c); } return sum?sum:len;}int main(){ int sum; while(scanf("%s",c)!=EOF) { if(strcmp(c,"END")==0) break; memset(t,0,sizeof t); len=strlen(c); for(int i=0;i<len;i++) t[c[i]]++; sum=huffman(); printf("%d %d %.1f\n",len*8,sum,(double)len*8/sum); } return 0;}
- POJ 1521 Entropy
- poj 1521 Entropy
- poj 1521 Entropy
- POJ 1521 Entropy
- POJ 1521 Entropy
- POJ - 1521 Entropy
- poj 1521 Entropy
- POJ 1521 , Entropy , Huffman
- POJ 1521-Entropy 贪心问题
- POJ 1521 Entropy(哈夫曼树)
- poj 1521(ENTROPY) huffman 编码
- POJ-1521/ZOJ-1117/Entropy
- 贪心1003 POJ 1521-Entropy
- hdu-1053-Entropy && poj-1521-Entropy (哈夫曼编码)
- POJ 1521 Entropy(哈夫曼编码)
- poj 1521 Entropy huffman(哈夫曼)编码
- poj 1521 Entropy(优先队列)
- POJ 1521 Entropy 优先队列/multiset
- Java IO 流的概括 图文讲解
- 求职面试时常被问到的65个问题与技巧性回答
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
- Matlab Startup Script
- C++面试题--寻找32位整数数组中第二大的数
- POJ 1521 Entropy
- C++数据结构--二分查找的递归和非递归实现
- C++基础知识
- Java实现日历
- JavaScript同样的意思,更巧的写法
- EOJ 2986~2990 2013年编程实践课程师范班第2次上机考试
- 黑马程序员 java Lock的使用
- linux驱动学习--第九天:第五章 Linux 文件系统与设备文件系统(三) 之 file 结构体 和 inode 结构体
- python 输出彩色文字