POJ 1862 Stripies (priority_queue 优先队列)
2017-01-13 21:29
411 查看
做法:
全部放入队列,每次去两个大的进行2 * sqrt(m1*m2 )
因为要使最终的结果最小,所以大的先进行开方,(是因为先进行合并的进行更多次开方)。
#include <iostream> #include <cstdio> #include <string.h> #include <queue> #include <cmath> typedef long long int lli; using namespace std; int main(){ int t; cin>>t; priority_queue<double,vector<double>,less<double> > q; int temp; for(int i = 1;i <= t;i++){ scanf("%d",&temp); q.push(temp); } while(q.size() > 1){ double a = q.top(); q.pop(); double b = q.top(); q.pop(); q.push(2*sqrt(a*b)); } double ans = q.top(); printf("%.3f\n",ans); }
相关文章推荐
- POJ 1862 Stripies priority_queue 单调队列
- POJ 1862 & ZOJ 1543 Stripies(贪心 | 优先队列)
- POJ 1862 Stripies (贪心、优先队列)
- POJ 1862 Stripies 贪心+优先队列
- POJ 1862 Stripies 贪心+优先队列
- poj1862~Stripies~贪心+优先队列
- POJ 1862 & ZOJ 1543 Stripies(贪心 | 优先队列)
- POJ 1862- Stripies(优先队列)
- poj 1862 priority_queue
- 优先队列(priority_queue)的cmp,POJ(2051)
- 关于优先队列(priority_queue)的使用
- STL - priority_queue(优先队列)
- POJ 2312Battle City(BFS-priority_queue 或者是建图spfa)
- POJ:1862 Stripies
- stack && queue && priority_queue 使用方法 (栈, 队列, 优先队列)
- POJ 1862 Stripies 贪心
- Poj 1862 Stripies【贪心+数学】
- POJ 1862 Stripies
- poj 2051 (用Priority_queue求解
- priority_queue(优先队列)用法总结