链接 http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1530

这个是典型的二分题,题目的意思就是给出朋友的个数还有饼的个数以及饼的半径,让你求出朋友以及自己最多可以分到多少的饼,并且分到的饼不可以是两块饼拼接的。要注意精度问题。

 #include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
const double eps=1e-;
const double pi=acos(-);
using namespace std;
int N,F;
int V[];
bool test(double x){
int ans=;
for(int i=;i<N;i++){
ans+=int(V[i]/x);
}
if(ans>=(F+))
return true;
else return false;
}
int main(){
int t;
cin>>t;
while(t--){
cin>>N>>F;
double max=0.0;
double low=0.0;
double mid;
for(int i=;i<N;i++){
cin>>V[i];
V[i]*=V[i];
if(V[i]>max)
max=V[i];
}
while(low+1e-<max){
mid=(max+low)/;
if(test(mid)==true)low=mid;
else max=mid;
}
mid*=acos(-);
printf("%.4f\n",mid);
}return ;
}

HRBUST1530的更多相关文章

随机推荐

  1. HTML5显示地图例子

    html 5获取GPS位置,Google地图显示 场景: JQuery Mobile 代码片段: <script type="text/javascript"> $(' ...

  2. VS2012远程调试(winform+web 远程调试)

    VS2012远程调试   一.调试WinFrom 程序 安装rtools_setup_x64 下载 配置Remote 启动Remote debugger 默认端口4016,选择工具-〉选项,选择 无身 ...

  3. android下asynchttp库对于session的支持

    默认asynchttp库不支持session,需要用户配置下cookie来处理,直接贴支持session的代码 package example.com.sessiontest; import andr ...

  4. 黄聪:WordPress根目录(Root)

    index.php:WordPress核心索引文件,即博客输出文件. license.txt:WordPress GPL许可证文件. my-hacks.php:定义了博客输出之前处理的追加程序.默认安 ...

  5. C#(结构体_枚举类型)

        结构体一般定义在Main函数上面,位于Class下面,作为一个类:一般情况Struct定义在Main函数前面,Main函数里面的地方都可以使用,参数前面加上public代表公用变量. 用法 1 ...

  6. bug_ _java.lang.IllegalArgumentException: View not attached to window manager

    ============= 1   view not attached to window manager 转自:http://hi.baidu.com/spare_h/blog/item/7fa3e ...

  7. ylbtech-Unitity-CS:Indexers

    ylbtech-Unitity-CS:Indexers 1.A,效果图返回顶部   1.B,源代码返回顶部 1.B.1, // indexer.cs // 参数:indexer.txt using S ...

  8. ipython and bpython

    ipython: 1.安装easy_install工具 wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py 2 ...

  9. MSSQL死锁产生原因及解决方法

    一.    什么是死锁 死锁是指两个或两个以上的进程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永远在互相等的进 ...

  10. 用R在字符串中提取匹配的部分

    例如在aaaa12xxxx中提取12,在参考了stackoverflow后比较方便的大致有以下几种方法: 利用sub跟gsub sub(".*?([0-9]+).*", " ...