每次合并最大的两个,优先级队列维护一下。

输出的时候%.3lf G++会WA,C++能AC,改成%.3f,都能AC。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std; int n,s;
priority_queue<double>Q; int main()
{
while(~scanf("%d",&n))
{
while(!Q.empty())Q.pop();
for(int i=; i<=n; i++)
{
double x;
scanf("%lf",&x);
Q.push(x);
} s=n;
if(s==)printf("%.3f\n",Q.top());
else
{
while()
{
double num1=Q.top();
Q.pop();
s--;
double num2=Q.top();
Q.pop();
s--;
Q.push(*sqrt(num1*num2));
s++;
if(s==)
{
printf("%.3f\n",Q.top());
break;
}
}
}
}
return ;
}

POJ 1862 Stripies的更多相关文章

  1. poj 1862 Stripies/优先队列

    原题链接:http://poj.org/problem?id=1862 简单题,贪心+优先队列主要练习一下stl大根堆 写了几种实现方式写成类的形式还是要慢一些... 手打的heap: 1: #inc ...

  2. POJ 1862 Stripies 贪心+优先队列

    http://poj.org/problem?id=1862 题目大意: 有一种生物能两两合并,合并之前的重量分别为m1和m2,合并之后变为2*sqrt(m1*m2),现在给定n个这样的生物,求合并成 ...

  3. POJ 1862 Stripies (哈夫曼树)

    Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10263   Accepted: 4971 Descrip ...

  4. POJ 1862 Stripies【哈夫曼/贪心/优先队列】

    Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 18198   Accepted: 8175 Descrip ...

  5. STL 训练 POJ - 1862 Stripies

    Description Our chemical biologists have invented a new very useful form of life called stripies (in ...

  6. POJ 1862 Stripies#贪心(水)

    (- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<cmath> #include<algorithm ...

  7. POJ 1862 Stripies 【优先队列】

    题意:科学家发现一种奇怪的东西,他们有重量weight,如果他们碰在一起,总重变成2*sqrt(m1*m2).要求出最终的重量的最小值. 思路:每次选取质量m最大的两个stripy进行碰撞结合,能够得 ...

  8. POJ 1862 &amp; ZOJ 1543 Stripies(贪心 | 优先队列)

    题目链接: PKU:http://poj.org/problem?id=1862 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...

  9. 【贪心】Stripies POJ 1862

    题目描述:http://poj.org/problem?id=1862 题目大意:你有n个数要合并,每两个数x,y合并后得到2*sqrt(x*y).求最后留下的一个数的最小值. 每合并一次,就会有数被 ...

随机推荐

  1. Arch: Configurations

    the original purpose is to show the steps needed to setup i3 in vbox.. easy. alright, it is a bit mi ...

  2. curl file_get_contents fsockopen

    三种处理的方式:     curl     file_get_contents     fsockopen fsockopen 是比较底层的调用,属于网络系统的socket调用,而curl经过的包装支 ...

  3. Firebase 相关

    谷歌在 2016年 I/O 大会上推出了 Firebase 的新版本.Firebase 平台提供了为移动端(iOS和Android)和 Web 端创建后端架构的完整解决方案. 从一开始的移动后端即服务 ...

  4. Android中的对话框AlertDialog使用技巧合集-转载

    Android中的对话框AlertDialog使用技巧合集     文章来自:http://blog.csdn.net/blue6626/article/details/6641105   今天我用自 ...

  5. 提高MySQL查询速度

    参考百度知道 关于mysql处理百万级以上的数据时如何提高其查询速度的方法 最近一段时间由于工作需要,开始关注针对Mysql数据库的select查询语句的相关优化方法. 由于在参与的实际项目中发现当m ...

  6. acm课程练习2--1003

    题目描述 My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a numb ...

  7. Linux学习 -- 系统管理

    1 进程管理 判断服务器健康状态 top [选项] 查看系统中所有进程 ps aux      BSD格式 ps -le        Linux格式 pstree [选项] -p   显示PID - ...

  8. Light OJ 1008

    找规律. 首先令n=sqrt(s),上取整.讨论当n为偶数时,若n*n-s<n则x=n,y=n*n-s+1否则x=-n*n+2*n+s-1,y=n;如果n为奇数,交换x,y即可,对称的. Sam ...

  9. 错误: error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. 的处理方法

  10. MiniProfiler找不到jquery的

    我一直在使用MiniProfiler来衡量网站性能.当我从1.9版本升级到2.0,它停止工作.我改变了命名空间从MvcMiniProfiler StackExchange.Profiling的.但是, ...