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的更多相关文章
随机推荐
- 给Jquery动态添加的元素添加事件2
$('div').on('click', 'button', function(e){console.log($(e.target).is(':button'))}); $('<button&g ...
- linux 编译安装nginx,配置自启动脚本
本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装nginx,记录下安装过程: 参照这篇文章:Linu ...
- 【转】ASP.NET MVC 的最佳实践
[This post is based on a document authored by Ben Grover (a senior developer at Microsoft). It is ou ...
- div的打开与关闭js
<script type="text/javascript"> var BoxHeight=$('.t_c').css("height"); //$ ...
- 文件压缩与挤压ZIP
/// <summary> /// Zip压缩与解压缩 /// </summary> public class ZipHelper { /// <summary> ...
- SVN:通过Client端打tag
教你如何使用svnClient打tag~给公司人用的! 1.进入代码主目录 2.右击空白处“TortoiseSVN”—->“Branch/tag” 3.点地址栏右侧的 (选择tags存放目录) ...
- 25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If ...
- duplicate symbols
duplicate symbol _mCollecatView in: /Users/Rubert/Library/Developer/Xcode/DerivedData/ChengDuHidengD ...
- OAF_OAF Exception Handling异常处理(概念)
2014-06-12 Created By BaoXinjian
- POJ_1287_mst
Networking Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6432 Accepted: 3488 Descri ...