poj 1521】的更多相关文章

http://poj.org/problem?id=1521 题意:给你一个字符串,首先是计算出一个按正常编码的编码长度,其次是计算出一个用霍夫曼编码的编码长度,最后求正常编码的长度除以霍夫曼编码长度的值,保留一位小数. 思路:正常的编码长度的话,由于都是ASCII码值所以编码长度都为8,所以总长度就是8*字符串的长度Len,然后霍夫曼编码的话,discuss里面很多人都是用优先队列,用优先队列的话,就不用自己维护了,我没用采用优先队列,而是一直维护一个递减的数组,这样的效果和有优先队列是一样的…
题目链接:http://poj.org/problem?id=1521 Entropy Time Limit: 1000MS    Memory Limit: 10000K Description An entropy encoder is a data encoding method that achieves lossless data compression by encoding a message with "wasted" or "extra" info…
题目链接:http://poj.org/problem?id=1521 这里,网上有很多博客都有写,很多人没有建树,直接就是求一下这个哈夫曼编码的长度,的确很巧妙,我也用的这个方法,但是,几乎所有博客都没有解释sum+=a+b;这个的原因.也许是我太菜了吧,脑子转不过来,好久才想通. 比如说B,C,D出现2次,BC组成一个新的节点,4+2=6,组成一个新的节点6,6+A就是结果. 原因是: sum+=2+2; sum+=4+2; sum+=6+5; 理由是,B,C分别编码是3位,这里依次加到了s…
poj.org/problem?id=1521 注意只有特殊情况:只有一种字母 #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<queue> #include<cmath> #include<map> using namespace std; ; char st…
此文来自北京邮电大学ACM-ICPC集训队 此50题在本博客均有代码,可以在左侧的搜索框中搜索题号查看代码. 以下是原文: POJ推荐50题1.标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉.2.标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目.3.列表中大约有70个题目.大家选做其中的50道,且每类题目有最低数量限制.4.这里不少题目在BUPT ACM FTP上面都有代码,请大家合理利用资源.5.50个题目要…
http://poj.org/problem?id=1719 Shooting Contest Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4135   Accepted: 1521   Special Judge Description Welcome to the Annual Byteland Shooting Contest. Each competitor will shoot to a target whi…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…