POJ_1862 Stripies 【贪心】
一、题面
二、分析
反省一下,自己英语水平着实不行,该题其实就是问若给出若干个这种生物,根据这种体重变换方式,最终合并成一个后,体重最少是多少。根据公式
$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 【贪心】的更多相关文章
- POJ1862 Stripies 贪心 B
POJ 1862 Stripies https://vjudge.net/problem/POJ-1862 题目: Our chemical biologists have invented ...
- POJ 1862 Stripies#贪心(水)
(- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<cmath> #include<algorithm ...
- POJ 1862 Stripies 贪心+优先队列
http://poj.org/problem?id=1862 题目大意: 有一种生物能两两合并,合并之前的重量分别为m1和m2,合并之后变为2*sqrt(m1*m2),现在给定n个这样的生物,求合并成 ...
- POJ 1862 & ZOJ 1543 Stripies(贪心 | 优先队列)
题目链接: PKU:http://poj.org/problem?id=1862 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...
- (贪心和优先队列) POJ1862 Stripies
Stripies Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21506 Accepted: 9478 Descrip ...
- 【POJ】1862:Stripies【贪心】【优先队列】
Stripies Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20456 Accepted: 9098 Descrip ...
- 【POJ - 1862】Stripies (贪心)
Stripies 直接上中文了 Descriptions 我们的化学生物学家发明了一种新的叫stripies非常神奇的生命.该stripies是透明的无定形变形虫似的生物,生活在果冻状的营养培养基平板 ...
- URAL 1161 Stripies(数学+贪心)
Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...
- Stripies(POJ 1862 贪心)
Stripies Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14151 Accepted: 6628 Descrip ...
随机推荐
- spring框架 事务 xml配置方式
user=LF password=LF jdbcUrl=jdbc:oracle:thin:@localhost:1521:orcl driverClass=oracle.jdbc.driver.Ora ...
- 搭建大数据hadoop完全分布式环境遇到的坑
搭建大数据hadoop完全分布式环境,遇到很多问题,这里记录一部分,以备以后查看. 1.在安装配置完hadoop以后,需要格式化namenode,输入指令:hadoop namenode -forma ...
- Hyperledger Fabric源码解析
Hyperledger Fabric开源于2015年12月,截至2018年2月初有185个公司/组织成员加入.最初由IBM和DAH的工程师贡献,现在约有70名的代码贡献者,4000+代码提交,代码行数 ...
- jquery中children()
- 跨库连接报错Server 'myLinkedServer' is not configured for RPC
Solution: Problem is most likely that RPC is not configured for your linked server. That is not a de ...
- ASP.NET MVC5 Authentication Filters执行链
注意区分认证和授权: The following are the differences in short: Authentication(认证): It is a process of verif ...
- Controller级别的异常处理过滤器IExceptionFilter
1,系统自带的HandleErrorAttribute类继承自IExceptionFilter,是MVC的默认实现. 同时设置web.config <system.web> <cus ...
- iOS CocoaPods安装与使用 好东西保存
http://www.cnblogs.com/daguo/p/4097263.html http://www.cnblogs.com/pican/p/3939941.html?utm_source=t ...
- jstl c
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 例子:list中有两 ...
- 《Wonderland: A Novel Abstraction-Based Out-Of-Core Graph Processing System》章明星
在2018年3月28日于美国弗吉尼亚州威廉斯堡结束的ACM ASPLOS 2018会议上,计算机系高性能所师生发表了两篇长文.一篇是我系博士生章明星为第一作者,导师武永卫为通讯作者的“Wonderla ...