POJ1862 Stripies 贪心 B】的更多相关文章

POJ 1862 Stripies https://vjudge.net/problem/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 n…
Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21506   Accepted: 9478 Description Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, bu…
思路: 简单贪心. 实现: #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; ], n; bool cmp(const int & a, const int & b) { return a > b; } int main() { cin >> n; ; i < n; i++)…
(- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; int main() { int n; ]; while(~scanf("%d",&n)) { ;i<n;i++) { int m; scanf("%d",&m); w[i]=m*1.0; } s…
http://poj.org/problem?id=1862 题目大意: 有一种生物能两两合并,合并之前的重量分别为m1和m2,合并之后变为2*sqrt(m1*m2),现在给定n个这样的生物,求合并成一个的最小重量 思路: m1+m2 >=  2*sqrt(m1*m2) 所以每次取大的去合并,能变小. 直接优先队列就可以啦. #include<cstdio> #include<cmath> #include<queue> using namespace std;…
POJ3617 Best Cow Line 题意 给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下列任意操作: 从S的头部(或尾部)删除一个字符,加到T的尾部 目标是构造字典序尽可能小的字符串T. 思路 贪心算法,不断取S的开头和末尾中较小的一个字符放到T的末尾.但对于S的开头和末尾字符相同的情况下,需要比较下一个字符大小,这可以用如下算法实现: 按照字典序比较S和S翻转后的字符串S1,如果S较小,则从S的开头取,否则从末尾取. 代码 Source Cod…
Stripies 直接上中文了 Descriptions 我们的化学生物学家发明了一种新的叫stripies非常神奇的生命.该stripies是透明的无定形变形虫似的生物,生活在果冻状的营养培养基平板菌落.大部分的时间stripies在移动.当他们两个碰撞,会有新stripie生成,而旧的不见了.经过长期研究,他们发现新stripies的体重不等于消失的stripies的体重,而是:如果一个质量为m1和m2的stripies相撞,生成的stripies体重是2*sqrt(m1*m2) 现在,科学…
题目链接: PKU:http://poj.org/problem?id=1862 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=543 Description Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian -…
Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20456   Accepted: 9098 Description Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, bu…
一.题面 POJ1862 二.分析 反省一下,自己英语水平着实不行,该题其实就是问若给出若干个这种生物,根据这种体重变换方式,最终合并成一个后,体重最少是多少.根据公式 $m = 2\sqrt{m_{1}m_{2}}$ 我们可以发现,就是一个开根号,那么为了能够得到更小的体重,肯定要让体重大的先合并,这样大的体重会被后面多次开根号,变得越来越小.这就是贪心策略. 三.AC代码 #include <cstdio> #include <iostream> #include <qu…