记得用PI=acos(-1)反三角函数求,用一次排序,然后二分和贪心

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
class Pie{
public:
double r;
double s;
};
bool Check(Pie p[], int n, int f, double x);
bool Cpm(Pie&a, Pie&b){
return a.r>b.r;
}
int main(){
Pie p[];
int i, n, f, Case;
double left, right, mid, pi =acos(-);
cin >> Case;
while (Case--){
cin >> n >> f;
f++;
for (i = ; i < n; i++){
cin >> p[i].r;
p[i].s = p[i].r*p[i].r*pi;
}
sort(p, p + n, Cpm); //按面积从小大大排序
left = 0.0, right = p[].s; //左右边界
while (right - left>1e-){
mid = (left + right)/;
if (Check(p, n, f, mid))
left = mid;
else
right = mid;
}
cout <<setiosflags(ios::fixed)<<setprecision()<<(left+right)/<< endl;
}
return ;
}
bool Check(Pie p[],int n,int f, double x){//检查是否可以满足条件
int i = , peo = ;
for (i = ; i < n; i++){
peo += int(p[i].s / x);
if (peo >=f)
return ;
}
return ;
}

HDU1969的更多相关文章

  1. HDU2199,HDU2899,HDU1969,HDU2141--(简单二分)

    二分是一种很有效的减少时间开销的策略, 我觉得单列出二分专题有些不太合理, 二分应该作为一中优化方法来考虑 这几道题都是简单的使用了二分方法优化, 二分虽然看似很简单, 但一不注意就会犯错. 在写二分 ...

  2. *HDU1969 二分

    Pie Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  3. 二分法经典习题——HDU1969

    #include <iostream>#include <cmath>#include <iomanip>using namespace std; double p ...

  4. HDU1969:Pie(二分)

    Pie Time Limit : 5000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submissio ...

  5. Hdu1969 Pie 2017-01-17 13:12 33人阅读 评论(0) 收藏

    Pie Time Limit : 5000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submissio ...

  6. HDU1969 Pie(二分搜索)

    题目大意是要办生日Party,有n个馅饼,有f个朋友.接下来是n个馅饼的半径.然后是分馅饼了, 注意咯自己也要,大家都要一样大,形状没什么要求,但都要是一整块的那种,也就是说不能从两个饼中 各割一小块 ...

  7. Cable master--hdu1551(二分法)

    Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

随机推荐

  1. MOCTF 简单注入

    最近在练习sql注入写脚本,记录一下思路,刚学的and 1=1也拿出来溜溜 http://119.23.73.3:5004/?id=1 首先,没有被过滤是正常显示. 没有被过滤但是查询不到就是空白,比 ...

  2. python - 接口自动化测试 - HttpRequest - 接口测试类封装

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: http_request.py @ide: PyCharm ...

  3. python中 in, any 和 all用法

    in if x == 1 or y == 1 or z == 1: print('passed') if 1 in (x, y, z): print('passed') any if x or y o ...

  4. hdu 4185 二分图最大匹配

    Oil Skimming Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  5. 【bzoj4825】[Hnoi2017]单旋 线段树+STL-set

    题目描述 H 国是一个热爱写代码的国家,那里的人们很小去学校学习写各种各样的数据结构.伸展树(splay)是一种数据结构,因为代码好写,功能多,效率高,掌握这种数据结构成为了 H 国的必修技能.有一天 ...

  6. ZOJ 2676 Network Wars(最优比例最小割)

    Network Wars Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge Network of Bytelan ...

  7. 百度地图API 根据地址查询经纬度

    html页面.引用上API: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> ...

  8. nodeJS学习(6)--- Sublime Text3 配置Node.js 开发环境

    参考:http://www.bubuko.com/infodetail-798008.html http://www.cnblogs.com/bluesky4485/p/3928364.html 1. ...

  9. Flex布局--必然的选择

    这篇文章是我在阮一峰老师的flex布局教程下,按照自己的理解重写写一遍,以便增强理解.如果你来到这里最好去看一下阮一峰大神的Flex布局教程 正式开始自己的. 说起布局方式,大家首先要了解css3有哪 ...

  10. 控制cxGrid 主从表的明细只展开一个

    procedure TForm.ADetailDataControllerCollapsing( ADataController: TcxCustomDataController; ARecordIn ...