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. Matrix Power Series(POJ 3233 构造新矩阵求解+ 快速矩阵幂)

    题目大意:给定A,k,m(取模),求解S = A + A2 + A3 + … + Ak. 思路:此题为求解幂的和,一开始直接一个个乘,TLE.时间消耗在累加上.此处巧妙构造新矩阵 p=    A 0 ...

  2. Core Data (一)备

    序 恩,用Core Data也有一段时间了.大大小小的坑也都坑过了.重来没有认真的记录一次.这次需要好好的理一理Core Data.就当一次绝好的机会记录下来.也为了自己加深认识. 为什么要用Core ...

  3. Autolayout-VFL语言添加约束-备

    一.VFL语言简介 VFL(Visual format language)语言是苹果为了简化手写Autolayout代码所创建的专门负责编写约束的代码.为我们简化了许多代码量. 二.使用步骤 使用步骤 ...

  4. log4c 编译安装简单小结(ubuntu12)

    1 下载源码,解压 (假定解压到了当前用户的根目录下,位置是~/log4c-1.2.3) 2 编译安装log4c(指定--prefix极其重要,如果没有指定到/usr下会有一堆麻烦事,还有,不能按照他 ...

  5. ListView中RadioButton实现单项选择

    1:FragmentHack5.java public class FragmentHack5 extends Fragment { View view; ListView lvCountries; ...

  6. Calculate Number Of Islands And Lakes 解答

    Question 1 1 1 1 1 01 0 1 0 0 11 0 1 0 0 11 1 0 1 1 1 1 is earth, 0 is water. i) count the number of ...

  7. 事件处理原理(IOS篇) by sixleaves

    前言 了解IOS事件处理的本质关键要先掌握几个概念.首先是事件的派发(Event Delivery)的过程, 一个是响应者链条如何构成. 事件的派发: Q1: 你有没有想过,如果你一个屏幕中有多个的V ...

  8. 用dTree组件生成无限级导航树

     在做管理系统时不可避免要用到导航树,这种东西只要一次做好,就可以随处运行,目前比较好的组件是dTree,原则上可以达到无限级,当然实际运行中4,5级就已经很多了,dTree的速度还是不错的,而且是J ...

  9. (转)Apache+Tomcat集群配置

    本文Apache+Tomcat集群配置 基于最新的Apache和Tomcat,具体是2011年4月20日最新的Tomcat和Apache集群和负载均衡配置. 准备环境 Apache Apache是ht ...

  10. 分割视图控制器(UISplitViewController) 改_masterColumnWidth 导致在 IOS 10中出现闪退

    默认UISplitViewController的Master和Detail的宽度是固定的,可以通过下面的方式来改变 [splitViewController setValue:[NSNumber nu ...