HRBUST1530
链接 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的更多相关文章
随机推荐
- Struts2 - Rest(1)
Struts2提供了一个restful的插件:struts2-rest-plugin-2.3.16.1.jar 这个插件可以把Struts2当做restful来使用,不过它的rest功能目前来说有点“ ...
- IOS开发小项目—找色块游戏
1.项目代码: @interface NextViewController () { int r ;//色块层数的全局变量 int m;//后面用于tag值的变化 UIView *view;//色块 ...
- php测试程序运行时间和占用内存情况
php测试程序运行时间和占用内存情况: $HeaderTime = microtime(true);//参数true表示返回浮点数值 /** *CODE */ printf(" total ...
- [备忘]Visio中连接线交叉时跨线小弯的去掉方法
连接线格式->行为->连接线->跨线->添加->从不 format->behavior…->Connector->Line jumps->Add: ...
- java.lang.ClassNotFoundException: org.eclipse.jetty.plus.webapp.EnvConfiguration
最近刚接触jetty,在myeclipse8.6中加入了一个项目,运行时就出了这个java.lang.ClassNotFoundException: org.eclipse.jetty.plus.we ...
- SchemaExport的使用
@Test public void testCreateDB(){ Configuration cfg = new Configuration().configure(); SchemaExport ...
- "this class is not key value coding-compliant for the key ..."问题的解决
今天出现跟着MJ的思路敲的代码,自己最后运行出现这个 错误,发现是 自己在将属性和相关联的控件连线时出现了 错误.一开始取名时出现了错误,发现线连重复了. 在网上又找到了一些出现该类错误的相关解释: ...
- spark IDEA开发环境搭建及运行问题
下图是例子: 还用说么,引入相关jar包(等下再一一说明) 包括scala,spark-assembly-1.4.1-hadoop2.5.0-cdh5.2.1.jar(按照你的spark和hadoo ...
- PLSQL_基础系列11_递归和层次查询CONNECT BY(案例)
2015-05-31 Created By BaoXinjian
- PLSQL_PLSQL读和写XML文件方式(案例)
2012-05-01 Created By BaoXinjian