POJ 1862
来源:互联网 发布:econometric python 编辑:程序博客网 时间:2024/06/08 00:09
今天的最后一道题了。。
23:59
在POJ上活捉刷题队长一只。
中间就隔了仨人
呃呃说正事
题意:
给几个数,合并的代价是 2*sqrt(x1*x2) 问n个数合并的代价最小值。
证明(Discuss里的):
假设有a,b,c 且结果是r
则 r = 2*sqrt(2*sqrt(a*b)*c)
则 r^2/8 = sqrt(a*b*c*c);
若要 r 最小 则 c 一定是 a,b,c 中最小的 所以就是不断地取两个大数相乘喽~~
再说一遍:STL大法好。(其实这道题sort一下也行,当时没有注意到这点)
// by Sirius_Ren#include <queue>#include <cmath>#include <cstdio>using namespace std;int main(){ priority_queue<double>pq; register double xx,yy,n; scanf("%lf",&n); while(n--)scanf("%lf",&xx),pq.push(xx); xx=pq.top();pq.pop(); while(!pq.empty())yy=pq.top(),pq.pop(),xx=2*sqrt(xx*yy); printf("%.3lf",xx);}
0 0
- poj 1862
- POJ 1862
- poj--1862
- poj 1862
- POJ 1862
- POJ 1862
- poj 1862
- 【POJ】1862
- POJ 1862
- poj 1862 priority_queue
- POJ 1862 Stripies (贪心)
- POJ 1862 Stripies
- POJ 1862 优先队列
- poj 1862 Stripies
- POJ 1862
- POJ:1862 Stripies
- poj 1862 Stripies
- POJ 1862 最小质量
- 12个非常实用的JavaScript小技巧
- 3.JAVA中常见的英文
- 开博第一篇:关于dw下的html编译问题
- JAVA vim 开发环境配置
- CSS清除浮动
- POJ 1862
- win8.1 11g r2 安装
- 老外的一份渗透测试报告
- 2016"百度之星" - 资格赛(Astar Round1)Problem A(乘法逆元)
- python基础练习(六)—— 绘图与可视化
- CSRF的防御
- 2016"百度之星" - 资格赛(Astar Round1)解题报告
- mac osx逆向工程
- 结合源码谈谈Activity的exported属性