ZOJ 1543 Stripies(哈夫曼贪心)
来源:互联网 发布:答题软件游戏 编辑:程序博客网 时间:2024/05/22 07:05
我用的是优先队列,每次选择最大的两个进行2*sqrt()操作,再压入队列.
#include <iostream>#include <memory.h>#include <queue>#include <vector>#include <cmath>#include <cstdio>#include <functional>using namespace std;priority_queue<double>q;int n;int main(){while (scanf("%d",&n)==1){while(q.size())q.pop();while (n--){int t;scanf("%d",&t);q.push(t);}while (q.size()>=2){double t1=q.top();q.pop();double t2=q.top();q.pop();q.push(2*sqrt(t1*t2));}printf("%.3lf\n",q.top());q.pop();}return 0;}
- ZOJ 1543 Stripies(哈夫曼贪心)
- POJ 1862 & ZOJ 1543 Stripies(贪心 | 优先队列)
- zoj 1543 Stripies
- 【瞎搞】 ZOJ 1543 Stripies
- POJ 1862 Stripies (贪心)
- POJ1862 Stripies 贪心
- [贪心]PKU Stripies
- POJ1862 Stripies 【贪心】
- [贪心]poj1862 Stripies
- 贪心算法之Stripies
- POJ 1862 Stripies 【贪心】
- POJ 1862 Stripies 贪心
- 【贪心】Stripies POJ 1862
- POJ-1862--贪心---Stripies
- POJ1862 Stripies (贪心)
- poj1862~Stripies~贪心+优先队列
- POJ 1862 - Stripies(贪心)
- POJ 1862 Stripies(数学贪心)
- C++11 - the new ISO C++ standard
- Ext表格控件和树控件
- Android学习笔记(一)
- POJ 3414 Pots
- [iOS代码] 打开App Store评论页面
- ZOJ 1543 Stripies(哈夫曼贪心)
- 数据库部分
- Win A Free Copy of Packt’s Managing Multimedia and Unstructured Data in the Oracle Database e-book
- 那些年我们疯狂的日子,文字控吧
- ubuntu 12.10 编译QtWebkit
- 我希望看到什么样的简历 by awflasher
- virbr0 虚拟网卡卸载方法
- Its not about the outage
- hdu 1372 Knight Moves 骑士的移动 bfs--马走日