//first thing:thanks to my teacher---chenrong Dalian Maritime university /* 构造Huffman Tree思路: (1)根据给点的n个权值{w1,w2,w3.....wn}构成n棵二叉树的集合F={T1,T2,T3......Tn},其中每棵二叉树只有个带有权值Wi的根节点,其左右子树为空. (2)在F中选取两棵根结点的权值最小的树作为左右子树构造一个新二叉树,新根权值为左右子树权值之和. (3)在F中delet
https://vjudge.net/problem/UVA-10954 题意:有n个数的集合S,每次可以从S中删除两个数,然后把它们的和放回集合,直到剩下一个数.每次操作的开销等于删除的两个数之和,求最小开销. 思路:Huffman编码. #include<iostream> #include<queue> using namespace std; struct cmp { bool operator()(const int a, const int b) const { ret