一、题面

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. IDEA02 利用Maven创建Web项目、为Web应用添加Spring框架支持、bean的创建于获取、利用注解配置Bean、自动装配Bean、MVC配置

    1 环境版本说明 Jdk : 1.8 Maven : 3.5 IDEA : 专业版 2017.2 2 环境准备 2.1 Maven安装及其配置 2.2 Tomcat安装及其配置 3 详细步骤 3.1 ...

  2. IDEA maven打包时跳过测试

    配置这个install -Dmaven.test.skip=true, 可以跳过business项目本地启动自动跑测试用例

  3. 面试题:SpringMVC的工作流程

    SpringMVC是当今最主流的Web MVC框架,没有之一,要做一名合格的JavaWeb工程师,学好它势在必行! 与Struts2原理不同,SpringMVC是通过最基础最传统的servlet来实现 ...

  4. 在Linux中监视IO性能

    dd命令 iostat命令 理解iostat的各项输出 iostat的应用实例 附:在Windows中监视IO性能 延伸阅读 dd命令 dd其实是工作于比较低层的一个数据拷贝和转换的*nix平台的工具 ...

  5. Part6-点亮指路灯_lesson1

    1. 2.GPIO 查阅芯片手册:GPIO 代码: 3.外设基地址初始化 打开arm核手册, 基地址为0x70000000,去搜芯片手册6410, 把这个基地址告诉处理器,通过协处理器的cp15, 转 ...

  6. 线程同步synchronized,wait,notifyAll 测试示例

    https://www.cnblogs.com/LipeiNet/p/6475851.html 一  synchronized synchronized中文解释是同步,那么什么是同步呢,解释就是程序中 ...

  7. plsql中的执行体

    在plsql中的sql windows窗口中,可以编写一段执行体来达到一定的目的,类似于写一段程序,可有逻辑判断. 大概的格式为 declare ----定义变量 begin ----- 执行体: e ...

  8. ASP.NET 5 Middleware, Or Where Has My HttpModule Gone?

    31 March 2015 13:22 ASP.NET 5 has been largely rewritten from the ground up, and incorporates some r ...

  9. Linq学习<一>

    lambda查询语法: var result =arrarylist.where(n=>n.contains("l"))  简化的委托方法实例 linq查询结构: var  ...

  10. 对request,session,application作用域形象理解

    看到一篇比较有意思的文章,分享一下.原网址:http://blog.csdn.net/rushkid02/article/details/8063792 几乎所有的Web开发语言都支持Session功 ...