poj 1862 Stripies

来源:互联网 发布:永暑礁 知乎 编辑:程序博客网 时间:2024/04/29 08:24

原题链接:http://poj.org/problem?id=1862

简单题,贪心+优先队列主要练习一下stl堆。。。

#include<cstdio>#include<cstdlib>#include<cmath>#include<queue>#include<iostream>int main(){#ifdef LOCAL    freopen("in.txt", "r", stdin);    freopen("out.txt", "w+", stdout);#endif    int n;    double a, b;    scanf("%d", &n);    std::priority_queue<double> ans;    while (n--){        scanf("%lf", &a);        ans.push(a);    }    while (ans.size() > 1){        a = ans.top(), ans.pop();        b = ans.top(), ans.pop();        ans.push(2 * sqrt(a * b));    }    printf("%.3lf", ans.top());    return 0;}

0 0
原创粉丝点击