1poj1862(贪心)
来源:互联网 发布:win10关闭软件快捷键 编辑:程序博客网 时间:2024/05/29 09:08
http://poj.org/problem?id=1862
Stripies
Time Limit: 1000MSMemory Limit: 30000KTotal Submissions: 9472Accepted: 4608
Description
Our chemical biologists haveinvented a new very useful form of life called stripies (in fact,they were first called in Russian - polosatiki, but the scientistshad to invent an English name to apply for an internationalpatent). The stripies are transparent amorphous amebiform creaturesthat live in flat colonies in a jelly-like nutrient medium. Most ofthe time the stripies are moving. When two of them collide a newstripie appears instead of them. Long observations made by ourscientists enabled them to establish that the weight of the newstripie isn't equal to the sum of weights of two disappearedstripies that collided; nevertheless, they soon learned that whentwo stripies of weights m1 and m2 collide the weight of resultingstripie equals to 2*sqrt(m1*m2). Our chemical biologists are veryanxious to know to what limits can decrease the total weight of agiven colony of stripies.
You are to write a program that will help them to answer thisquestion. You may assume that 3 or more stipies never collidetogether.
You are to write a program that will help them to answer thisquestion. You may assume that 3 or more stipies never collidetogether.
Input
The first line of the inputcontains one integer N (1 <= N <=100) - the number of stripies in a colony. Each of next N linescontains one integer ranging from 1 to 10000 - the weight of thecorresponding stripie.
Output
The output must contain one linewith the minimal possible total weight of colony with the accuracyof three decimal digits after the point.
Sample Input
3723050
Sample Output
120.000
Source
Northeastern Europe 2001, Northern Subregion
题意:已知n个数,一次两个按照2*sqrt(m1*m2)来结合,输出最小的结果
//思路:关键在于证明任意三个数如何结合,结果才能最小
假设有a,b,c 且结果是r
则 r = 2*sqrt(2*sqrt(a*b)*c)
则 r^2/8 = sqrt(a*b*c*c);
若要 r 最小 则 c 一定是 a,b,c 中最小的 所以就是不断地取两个大数相乘喽~~
我用测试数据计算了下发现每次发最大拿来计算就行了。
#include<iostream>
#include<algorithm>
#include<cmath>
double a[110];
using namespace std;
int main()
{
}
- 1poj1862(贪心)
- 贪心--poj1862
- poj1862 贪心
- POJ1862 Stripies 贪心
- POJ1862 Stripies 【贪心】
- [贪心]poj1862 Stripies
- POJ1862 Stripies (贪心)
- poj1862~Stripies~贪心+优先队列
- #POJ1862#Stripies(贪心 + 数学分析)
- poj1862
- poj1862
- poj1862
- (POJ1862)Stripies
- POJ1862-Stripies
- POJ1862 Stripies
- poj1862 哈夫曼水题
- [POJ1862]Stripies
- POJ1862 水
- 1poj1065(贪心)
- 1poj1716(贪心)
- poj2313(贪心)
- 1poj2370(贪心水)
- 1poj2209(贪心)
- 1poj1862(贪心)
- 1poj1922(贪心)
- poj1323(贪心)
- poj1503(大数相加)
- 大数加减乘除幂模版
- poj1050(dp最大子矩阵)
- poj1088(dfs||dp)
- poj1125(floyd最短路)
- poj1458(DP最长连续公共子序列)