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. fedora 23中配置tftp-server

    fedora 23中配置tftp-server */--> fedora 23中配置tftp-server Table of Contents 1. 简介 2. tftp安装 3. 启动和允许 ...

  2. Ubuntu 修改时间

    输入"date",显示的是: Tue Jan :: UTC 输入"date -R" 显示的是: Tue, Jan :: + 和北京时间相差了8个小时. 1.选择 ...

  3. 获取iframe 内元素的方法

    1,原生的方法 首先给iframe 设置 id 属性 var obj = document.getElementById('iframe').contentWindow; setTimeout(fun ...

  4. 까페24 호스팅 php 에러메세지 출력

    [문제점] 최근 까페24호스팅에서 php작업시화면에 에러메세지가 나오지 않아 디버깅시에 매우 곤란함 [해결책] .htaccess 내용에 아래추가.=================== ...

  5. Linux - 重定向与管道

    标准输出重定向 ">" 操作符:覆盖目标文件内容 huey@huey-K42JE:~/huey/linux/cmdline$ date > foo huey@huey- ...

  6. 【MINA】粘包断包处理

    1.先解释下什么叫粘包和断包 粘包 就是数据以字节的形式在网络中传输,一个数据包的字节可能经过多次的读取粘合才能形成一个完整的数据包 断包 一次读取的内容可能包含了两个或多个数据包的内容,那么我们必须 ...

  7. ASP.Net Core 运行在Linux(CentOS)

    Linux Disibutaion:CentOS 7.1 Web Server:Apache.Kestrel 1.安装.net core sudo yum install libunwind libi ...

  8. 设计模式------PROTOTYPE(原型),TEMPLATE(模板)

    看链接:http://blog.csdn.net/wuzhekai1985/article/details/6667020.纯属为自己学习所使用. 对于原型模式的理解:就如连接中所说,制作简历时先手写 ...

  9. 2013年全国各大著名的IT公司薪资待遇大揭密

    以下为转载,特此说明!--西电好网 ============================================ 1: 本人西电通院2013届毕业硕士,根据今年找工作的情况以及身边同学的汇 ...

  10. iOS获取webview高度

    int webHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scr ...