POJ 1862 Stripies(解题报告)

POJ - 1862:Stripies Stripies 来源:POJ 标签:贪心算法,优先队列 参考资料: 相似题目: 题目 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 sc... 阅读详情

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<math.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	double a[1001];
	int n,i,j;
	cin>>n;
	double temp;
	double max=-1,min;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		printf("%.3lf\n",a[0]);
	}
	else
	{
		sort(a,a+n);
		a[n-2]=2*sqrt(a[n-1]*a[n-2]);
		sort(a,a+n-1);
		for(i=n-2;i>0;i--)
		{
			a[i-1]=2*sqrt(a[i]*a[i-1]);
			sort(a,a+i);
		}
		printf("%.3lf\n",a[0]);
	}
 
	return 0;
}




Transformer是什么?看完这篇你就醍醐灌顶 前言 由谷歌团队提出的预训练语言模型BERT近年来正在各大自然语言处理任务中屠榜(话说学者们也挺有意思的,模型名都强行凑个芝麻街的人物名,哈哈哈)。 BERT算法的最重要的部分便是Transformer的概念,它本质上是Transformer的编码器部分。 而Transformer是什么呢?transformer是永远的神,自从transformer使用了抛弃rnncnn的纯attention机制之后,各种基于transformer结构的预训练模型都如雨后春笋般雄起,而transformer中最重要就是使用 阅读详情

相关推荐

Claude Code + 自定义模型体验

AI 编程工具的发展突飞猛进:Cursor 横空出世,推出了“Agent 模式”;新竞争者如 Windsurf 也纷纷加入战局。几乎所有产品都开始转向“代理式(agentic)”开发模式——不再依赖单次 LLM 响应进行补全,而是让大模型在一个循环中调用各种工具,来完成更复杂的任务:分析代码库上下文、读取网页与文档、编译程序、运行测试、修复失败构建或测试、不断迭代等。

西京刀客 5790

poj1862 哈夫曼水题

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

扬帆起航 674

电价预测的Transformer实战:从注意力机制到超长序列建模

本文深入探讨了Transformer模型在电价预测领域的实战应用,对比了其与LSTM在处理长序列依赖和误差累积问题上的优劣。文章详细解析了自注意力机制的原理,并提供了处理超长序列的位置编码方法、构建专用预测模型的完整PyTorch代码,以及防止信息泄露的关键技巧。通过实战对比,展示了Transformer在并行计算、长距离建模和预测精度上的显著优势,并分享了应对极端波动和提升模型效率的高级优化策略。

f6g7h8i9j的博客 540

贪心算法之Stripies

Stripies   Our chemical biologists have invented anew very useful form of life called stripies (in fact, they were first calledin Russian - polosatiki, but the scientists had to invent an English na

hqf1992的专栏 745

SFM(structure from motion 从运动恢复结构)和MVS(multi-view stereo 多视图立体视觉)

主要目的:SFM是重建稀疏点云的,MVS重建的是稠密点云。 输入的数据:SFM是没有标定的数据,而MVS输入的是标定的数据。 为什么SFM无法重建出稠密的点云,但是MVS可以? SFM中我们用来做重建的点是由特征匹配提供的!这些匹配点天生不密集!MVS则几乎对照片中的每个像素点都进行匹配,几乎重建每一个像素点的三维坐标,这样得到的点的密集程度可以较接近图像为我们展示出的清晰度。 SFM和MVS关系 SFM给MVS算好了输入视角的位姿,内参,稀疏点云以及它们的共视关系,MVS再利用这些信息以及彩色图

Vpn_zc的博客 1万+

2025年MathorCup数学应用挑战赛【B题完整论文】附参考代码(免费分享)

摘。

RS_handy的博客 2694

3.15课程总结——贪心

本周两堂课讲了很多贪心的题目,更新了我对贪心题目的认识,贪心题目的变化真的很多,贪心的策略更是各种各样。

Ashen1_的博客 403

排除 AcroForm 中 JavaScript 脚本的 Bug

本文介绍了Acrobat JavaScript脚本故障排除的基本方法。首先应检查控制台窗口的错误报告,通过具体示例演示了5类常见错误:语法错误(如缺少大括号)、未终止字符串、未定义变量、运算符混淆及变量作用域问题,并逐步给出修复方案。文章还提供了调试流程UML图和实用经验总结,强调关注细节(如分隔符匹配)、正确使用运算符和变量作用域等要点。最后建议采用系统化调试方法,包括关闭/重新打开表单等完整性测试。

小猫三两只。 1501

POJ 1862 优先队列

http://poj.org/problem?id=1862 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

ACM,再见! 1067

从实验室到生产线:Qwen3-Omni后训练技术在实际业务中的落地挑战

本文探讨了Qwen3-Omni后训练技术在实际业务中的落地挑战,重点分析了多模态AI在工业应用中的关键问题与解决方案。通过金融风控、跨境电商等场景案例,揭示了通用模型与垂直需求的矛盾,并提供了知识蒸馏、语音合成优化等实战经验,助力企业实现技术到业务的转化。

weixin_29035147的博客 266

在RStudio中使用GitHub Copilot:代码自动生成,从此告别手敲!

可以通过自定义提示词来引导Copilot生成符合自己需求的代码。再看一个做统计分析的。

Codewar的博客 330

POJ 1862 Stripies

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 Englis

Ailing 364

代谢组数据分析(二十八):基于广义估计方程(GEE)的方法探究代谢物与临床表型相关性

本研究利用广义估计方程(GEE)方法对代谢组学数据进行了深入分析,旨在探究代谢物与临床表型之间的相关性。代谢组学数据具有高维性、样本间相关性以及混杂因素的复杂性,传统的统计方法难以有效处理这些问题。GEE方法通过引入相关性结构,能够有效地处理样本间的相关性,并同时调整多个混杂因素,从而提高了分析结果的准确性和可靠性。

专注生信领域 1276

POJ 1862 Stripies 贪心

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 ...

RPG_Zero的博客 229

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

POJ1862-Stripies

天降正义!!! 【题目描述】 两条变形虫可以进行合并,合并后新的个体质量为2*sqrt(m1*m2),m1、m2是原来未合并前两条变形虫的质量。已知3条或3条以上变形虫无法进行合并。现在请你编程解决,当 N条变形虫进行两两合并,最后成为一条变形虫时,最小的质量为多少。 【输入】 第一行输入一个整数N(1<=N<=100),表示变形虫的数量。接下来N行每行包括一个1到1...

a1505150763的专栏 275

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

POJ 1862 Stripies(优先队列)

http://poj.org/problem?id=1862 题目大意: 给定一组数,对任意两个数字进行2*sqrt(m1*m2)的操作,要求所得的所有数最小。 解题思路: 贪心,由于会一直开方,那么越大的数字开的次方数越多整体数字越小。 采用优先队列处理即可。 AC代码: #include <cstdio> #include <cmath> #i...

Sensente的博客 289

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

(贪心5.2.5)POJ 1862 Stripies(利用数据有序化来进行贪心选择)

/* * POJ_1862.cpp * * Created on: 2013年10月11日 * Author: Administrator */ #include #include #include #include using namespace std; int main(){ int n; scanf("%d",&n); priority_queu

黄俊东的专栏 1193

Stripies POJ - 1862 (贪心+优先队列,注意输出)

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...

alex1997222的博客 355

Stripies POJ - 1862 ---优先队列

InputOutputSample3723050120.000。

qq_27445099的博客 129

POJ:1862-Stripies

Stripies Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 19144 Accepted: 8562 Description Our chemical biologists have invented a new very useful form of life called strip...

二营长的意大利炮友 207

Stripies(POJ 1862, 贪心)

题目链接        题目大意:有一种生物两个遇到后会合成一个质量为2sqrt(m1*m2),给你一些这种生物的质量,问合成的最小质量为多少。        解题思路:质量大的先被拿来合成        #include #include #include using namespace std; const int MAX_N = 105; int N; double ans; i

c138Rick的博客 478

POJ 1862-Stripies

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34178244的博客 153

POJ 1862 Stripies 优先队列

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 ...

hpuhjl的专栏 2772

POJ 1862 Stipies 解题报告

题意很简单,就是给定你一系列的数值,任意挑选其中两个数a和b,得到一个新的数2*sqrt(a*b),然后再将这个新的个放回。一直这样下去,直到只剩下一个数。求剩下的这个数最小是多少。 使用贪心策略,不断挑选两个最大的数组成一个新的数并放回原数列,再挑选最大的两个数……最到只乘一个数为止。   根据以上分析,知道使用C++STL中的priority_queue很简便。 以下是代码: #in

Leo的博客 1118

POJ 1862

Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20805   Accepted: 9248 Description Our chemical biologists have invented a new very useful form of life called s...

一只菜鸟夹 411
上一篇: POJ 3219 Binomial Coefficients
下一篇: A.yuna学数论(解题报告)
CSUST_ACM
博客等级 码龄15年 42粉丝 127原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值