Stripies
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 14151   Accepted: 6628

Description

Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an English name to apply for an international patent). The stripies are transparent amorphous amebiform creatures that live in flat colonies in a jelly-like nutrient medium. Most of the time the stripies are moving. When two of them collide a new stripie appears instead of them. Long observations made by our scientists enabled them to establish that the weight of the new stripie isn't equal to the sum of weights of two disappeared stripies that collided; nevertheless, they soon learned that when two stripies of weights m1 and m2 collide the weight of resulting stripie equals to 2*sqrt(m1*m2). Our chemical biologists are very anxious to know to what limits can decrease the total weight of a given colony of stripies. 
You are to write a program that will help them to answer this question. You may assume that 3 or more stipies never collide together. 

Input

The first line of the input contains one integer N (1 <= N <= 100) - the number of stripies in a colony. Each of next N lines contains one integer ranging from 1 to 10000 - the weight of the corresponding stripie.

Output

The output must contain one line with the minimal possible total weight of colony with the accuracy of three decimal digits after the point.

Sample Input

3
72
30
50

Sample Output

120.000

很不显然的显然,先尽量从大的取。
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
int main()
{
int n,i,j;
double w,a,b,sum;
priority_queue<double> s;
freopen("in.txt","r",stdin);
while(scanf("%d",&n)!=EOF)
{
for(i=;i<n;i++)
{
scanf("%lf",&w);
s.push(w);
}
while()
{
a=s.top();
s.pop();
if(s.empty())
break;
b=s.top();
s.pop();
s.push(*sqrt(a*b));
}
printf("%0.3lf\n",a);
}
}

Stripies(POJ 1862 贪心)的更多相关文章

  1. 【贪心】Stripies POJ 1862

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

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

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

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

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

  4. 【POJ - 1862】Stripies (贪心)

    Stripies 直接上中文了 Descriptions 我们的化学生物学家发明了一种新的叫stripies非常神奇的生命.该stripies是透明的无定形变形虫似的生物,生活在果冻状的营养培养基平板 ...

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

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

  6. POJ 1862 Stripies#贪心(水)

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

  7. poj 1862 Stripies/优先队列

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

  8. POJ 1862 Stripies (哈夫曼树)

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

  9. STL 训练 POJ - 1862 Stripies

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

随机推荐

  1. java中byte数组与int类型的转换(两种方式)

    http://blog.csdn.net/z69183787/article/details/38564219 http://blog.csdn.net/z69183787/article/detai ...

  2. Solr简单部署

    因为公司最近涉及这个项目,想了解一下,以便提供更好的支持.. 参考URL: http://www.centoscn.com/CentosServer/test/2014/1127/4193.html ...

  3. POJ 2653 Pick-up sticks(线段相交)

    题意:给定n个木棍依次放下,要求最终判断没被覆盖的木棍是哪些. 思路:快速排斥以及跨立实验可以判断线段相交. #include<algorithm> #include<cstdio& ...

  4. Linux下编译第三方库的问题

    因为各个Linux发行版之间的差异还是挺大的,有一些预安装在系统上的基本库是不一样的(不仅仅是版本,有一些是有和无的区别). 那么问题来了: 编译第三方库./configure的时候一般我们不会定制那 ...

  5. 10.1.5 Connection Character Sets and Collations

    10.1.5 Connection Character Sets and Collations Several character set and collation system variables ...

  6. 捆绑和缩小(BundleConfig.RegisterBundles) 第五章 : MVC中的使用 | {version}用法

    使用捆绑与 ASP.NET MVC 放缩法 在这一节我们将创建 ASP.NET MVC 项目,审查捆绑和缩小.首先,创建一个新的 ASP.NET MVC 互联网项目,命名为MvcBM ,而无需更改任何 ...

  7. Visual Assist X在Windows 8.1下出现中文乱码的解决方法

    这主要是输入法造成的,我的输入法中有US.中文.搜狗输入法三个输入法:通过搜狗输入法管理器把“中文”去掉,或者通过语言首选项把“中文”去掉就不会在出现乱码. 这个办法的思路来自于http://www. ...

  8. Makefile中使用foreach生成一类规则

    CSDN上,有朋友发帖问了这样一个问题(我按自己的理解翻译一下): 当前目录下有四个静态库文件:  liba.a libb.a libc.a libd.a.现在想将它们做成一个动态库libp.so. ...

  9. C# 制作 仪表

    以前在百度写的文档,转移到此处 前些天在做NetAnalyzer时,需要使用一个指针仪表,网上看了一下,也有人做过,但是大部分都是收费的,本着自力更生的原则,于是决定自己设计一个,今天拿出来有读者分享 ...

  10. [HDU 1535]Invitation Cards[SPFA反向思维]

    题意: (欧洲人自己写的题面就是不一样啊...各种吐槽...果断还是看晕了) 有向图, 有个源叫CCS, 求从CCS到其他所有点的最短路之和, 以及从其他所有点到CCS的最短路之和. 思路: 返回的时 ...