一、题面

POJ1862

二、分析

反省一下,自己英语水平着实不行,该题其实就是问若给出若干个这种生物,根据这种体重变换方式,最终合并成一个后,体重最少是多少。根据公式

$m = 2\sqrt{m_{1}m_{2}}$

我们可以发现,就是一个开根号,那么为了能够得到更小的体重,肯定要让体重大的先合并,这样大的体重会被后面多次开根号,变得越来越小。这就是贪心策略。

三、AC代码

 #include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
#include <fstream>
#include <cmath> using namespace std; const int MAXN = 1e2+;
int Data[MAXN]; int main()
{
//freopen("input.txt", "r", stdin);
int N;
while(scanf("%d", &N)!=EOF)
{
for(int i = ; i < N; i++)
scanf("%d", &Data[i]);
sort(Data, Data+N, greater<int>() );
double ans;
ans = Data[];
for(int i = ; i < N; i++)
{
ans = 2.0*sqrt(ans*Data[i]);
}
printf("%.03f\n", ans);
}
return ;
}

POJ_1862 Stripies 【贪心】的更多相关文章

  1. POJ1862 Stripies 贪心 B

    POJ 1862 Stripies https://vjudge.net/problem/POJ-1862 题目:     Our chemical biologists have invented ...

  2. POJ 1862 Stripies#贪心(水)

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

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

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

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

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

  5. (贪心和优先队列) POJ1862 Stripies

    Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21506   Accepted: 9478 Descrip ...

  6. 【POJ】1862:Stripies【贪心】【优先队列】

    Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20456   Accepted: 9098 Descrip ...

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

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

  8. URAL 1161 Stripies(数学+贪心)

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

  9. Stripies(POJ 1862 贪心)

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

随机推荐

  1. LoadRunner 脚本开发和常用函数

    开发性能测试脚本原则.简单 正确 高效 在lr中,脚本运行是解释执行的.所以在运行时,需要先编译. 局部变量和全局变量 1.在init.action.end中定义的变量就是局部变量 2.在global ...

  2. ubuntu下不用eclipse开发cocos2d-x(命令行)

    之前在ubuntu下通过eclipse搭建开发cocos2d-x的环境,但是由于eclipse界面在ubuntu显得很丑,在里面写代码,完全没有感觉,后来我转到了win7上通过vs2010和eclip ...

  3. 怎样使用Mock Server

    转载自:http://www.cnblogs.com/111testing/p/6091460.html 怎样使用Mock Server   一,去这里https://github.com/dream ...

  4. 基于PCL的屏幕选点、框选点云、单点选取

    1. 单点选取 #include <pcl/io/pcd_io.h> #include <pcl/point_cloud.h> #include <pcl/point_t ...

  5. SQLAlchemy(ORM框架)

    SQLAlchemy SQLAlchemy概述 2 3 4 5 6 7 8 9 10 11 12 13 MySQL-Python     mysql+mysqldb://<user>:&l ...

  6. swing中的分层

    swing中的分层 摘自:https://blog.csdn.net/levelmini/article/details/26692205 2014年05月23日 12:42:56 阅读数:1244 ...

  7. Mac OS 10.8 中的 OpenGL 开发环境设置(转)

    转自:http://www.th7.cn/Program/cp/201305/137743.shtml 一.XCode 4.5 在项目的"Build Phases">&quo ...

  8. 使用dockerfile-maven-plugin发布docker到私有仓库

    要想拥有私有docker仓库,需要安装registry镜像,最新版时2.0,具体可以看文档:https://docs.docker.com/registry/. 1. docker pull regi ...

  9. 关于AJAX与JSON的杂记

    一.当网页需要有多个XMLHttpRequest对象时,可以使用Callback 函数,callback 函数是一种以参数形式传递给另一个函数的函数. <html> <head> ...

  10. 20145218PC平台逆向破解

    20145218PC平台逆向破解 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. 该程序同 ...