My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though. My friends are very annoying and if one of them gets a bigger piece than the others, they start complaining. Therefore all of them should get equally sized (but not necessarily equally shaped) pieces, even if this leads to some pie getting spoiled (which is better than spoiling the party). Of course, I want a piece of pie for myself too, and that piece should also be of the same size. What is the largest possible piece size all of us can get? All the pies are cylindrical in shape and they all have the same height 1, but the radii of the pies can be different.

Input

One line with a positive integer: the number of test cases. Then for each test case: • One line with two integers N and F with 1 ≤ N, F ≤ 10000: the number of pies and the number of friends. • One line with N integers ri with 1 ≤ ri ≤ 10000: the radii of the pies.

Output

For each test case, output one line with the largest possible volume V such that me and my friends can all get a pie piece of size V . The answer should be given as a oating point number with an absolute error of at most 10−3 .

Sample Input

3

3 3

4 3 3

1 24

5

10 5

1 4 2 3 4 5 6 5 4 2

Sample Output

25.1327

3.1416

50.2655

题目大意:主人家里来了F个他的朋友,他家里有n个Pie,主人希望把Pie分出F+1份,体积相同(包括主人),所有的Pie不需要都分完,问你每个人最大能分到多大体积的Pie。

主要是猜那个二分最小值x,对,就是猜。

#include <iostream>
#include <cstdio>
#include<cmath>
using namespace std;
double pi=acos(-1.0); // 圆周率的表示。。。
int T,n,f;
double b[];
int juge(double x)
{
int total =;
for(int i=; i<=n; i++)
{
total+=int(b[i]/x);
}
if(total>f)
return ;
else
return ;
}
int main()
{
double l,r,mid,rad;
cin>>T;
while(T--)
{
cin>>n>>f;
double sum=;
for(int i =; i<=n; i ++)
{
cin>>rad;
b[i]=rad*rad*pi;
sum+=b[i];
}
l=;
double r=sum/(f+);
while(r-l>0.0001) // 此题精度小数点后四位
{
mid=(l+r)/;
if(juge(mid))
l=mid;
else
r=mid;
}
printf("%.4lf\n",mid);
}
return ;
}

HDU 1969 Pie(二分法)的更多相关文章

  1. hdu 1969 Pie (二分法)

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

  2. hdu 1969 Pie(二分查找)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1969 Pie Time Limit: 5000/1000 MS (Java/Others)    Me ...

  3. HDU 1969 Pie(二分查找)

    Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...

  4. HDU 1969(二分法)

    My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...

  5. HDU 1969 Pie(二分搜索)

    题目链接 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pi ...

  6. HDU 1969 Pie(二分,注意精度)

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

  7. HDU 1969 Pie【二分】

    [分析] “虽然不是求什么最大的最小值(或者反过来)什么的……但还是可以用二分的,因为之前就做过一道小数型二分题(下面等会讲) 考虑二分面积,下界L=0,上界R=∑ni=1nπ∗ri2.对于一个中值x ...

  8. 题解报告:hdu 1969 Pie(二分)

    Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...

  9. hdu 1969 pie 卡精度的二分

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

随机推荐

  1. 浅谈ASP脚本的解释

    10多年前,ASP的出现使全世界的WEB设计者摆脱了C/C++的繁杂,大幅提升了页面的开发效率 然而一直到数年之后,asp的解释一直握在微软手里,后来阿帕奇也支持asp了,虽然没有IIS那么强大,但是 ...

  2. javascript 标签 src 链接动态文件。

    test.html中的代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...

  3. Routing and controllers

    Routing and controllers We will build a very simple inventory system to display our album collection ...

  4. Java基础知识强化之网络编程笔记20:Android网络通信之 Android常用OAuth登录和分享

    1.  申请百度开发者账号及百度OAuth简介. (1)申请开发者账号: http://developer.baidu.com/ (2)创建项目: http://developer.baidu.com ...

  5. 第二次作业第3题_JH

    3.完成小组的“四则运算”项目的需求文档(使用Markdown写文档),尝试同组成员在各自PC上修改同一文档后,如何使用Git命令完成GitHub上的文档的更新,而不产生冲突.并验证GitHub上的文 ...

  6. servlet案例

    1.重定向 方式1:在servlet中写:response.setStatus(302);      response.setHeader("Location","路径& ...

  7. UILabel 自动换行 和支持换行符

    这个主要是 lable对\n换行符号的支持,有的时候我们从网页或者后台拿到的数据需要处理一下: 这里没什么要说的,注意两点,一个是label的numofline属性的值要为0 或者不能为1  这样la ...

  8. 转:vim----复制粘贴

    vim有12个粘贴板,分别是0.1.2.....9.a.“.+:用:reg命令可以查看各个粘贴板里的内容.在vim中简单用y只是复制到“(双引号)粘贴板里,同样用p粘贴的也是这个粘贴板里的内容: 要将 ...

  9. Thinkphp kindeditor 内容转义

    参考了:[解决]ThinkPHP整合Html编辑器时出现自动转义的问题 遇到问题也是保存到数据库中的内容,会转义成“\"” 使用 $data['content'] = stripslashe ...

  10. 20160611-20160714springmvc入门进阶

    springmvc第二阶段 高级知识 复习: springmvc框架: DispatcherServlet前端控制器:接收request,进行response HandlerMapping处理器映射器 ...