链接 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. object-单例设计模式

    1.什么是单例?       单例是一种数据共享的方法,其实就是等同于c语言中的全局变量.在整个程序生命周期内,该对象只有一份存在内存中,可以在多个对象之间共享数据 单例其实就相当于一个类只能有一个实 ...

  2. Microsoft SQL Server Management Studio 导出触发器脚本

  3. Configure custom SSL certificate for RDP on Windows Server 2012 in Remote Administration mode

    Q: So the release of Windows Server 2012 has removed a lot of the old Remote Desktop related configu ...

  4. [tty与uart]3.tty驱动分析

    转自:http://www.wowotech.net/linux_kenrel/183.html 目录: 1 首先分析设备驱动的注册 1.1 uart_register_driver分析 1.2 tt ...

  5. c++中ifstream读文件的问题(关于eof())

    今天帮别人找BUG,是一段关于c++读写文件的问题,使用的是ifstream与outstream类,关于ofstream与ifstream的用法,此处不再獒述,见代码: #include<ios ...

  6. 一次非常有意思的 SQL 优化经历

    我用的数据库是mysql5.6,下面简单的介绍下场景 课程表 create table Course( c_id int PRIMARY KEY, name varchar(10) ) 数据100条 ...

  7. Android 自定义ScrollView 支持惯性滑动,惯性回弹效果。支持上拉加载更多

    先讲下原理: ScrollView的子View 主要分为3部分:head头部,滚动内容,fooder底部 我们实现惯性滑动,以及回弹,都是靠超过head或者fooder 就重新滚动到  ,内容的顶部或 ...

  8. 在编译oc中protocol时出现的错误

    Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ...

  9. NodeJS 学习资料

    1. npm 除Node本身提供的API外,现在有不少第三方模块可极大的提高开发效率,npm就是Node的软件包管理器,可以用它安装所需软件包并发布自己为nodejs写的软件包. npm安装node扩 ...

  10. map遍历测试结果

    结论:一般情况下推荐使用enterSet的for循环(即以下的方法2),如果只是取key值可以使用keySet性能会更好. 因为keySet只取key,enterSet即取了key又取了value. ...