Problem Description

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 <= 10 000: the number of pies and the number of friends.
---One line with N integers ri with 1 <= ri <= 10 000: 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 floating 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

Source

NWERC2006
 #include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int pi,pe,num;//pi是派的数量,pe是人的数量,num是可以分到的人数
double pie[];//pie的大小
double mi,ma,mid;//最少能分到的和最多能分到的,mid是二分法的中间变量
double pai=acos(-1.0);//pi的定义
int main()
{
int T;
cin>>T;
while(T--)
{
cin>>pi>>pe;
pe++;//pe个朋友加上自己
ma=0.0;
mi=0.0;
for(int i=;i<pi;i++)
{
cin>>pie[i];
pie[i]=pai*pie[i]*pie[i];
ma+=pie[i];
if(pie[i]>mi)
mi=pie[i];
}
ma/=pe;
mi/=pe;
while(mi+0.00001<ma)//因为两个都是double型无法相等所以+0.0001控制
{
mid=(ma+mi)/;
num=;
for(int i=;i<pi;i++)
{
num+=(int)(pie[i]/mid);
}
if(num>=pe)mi=mid;//足够,往大继续二分
else ma=mid;//不够,往小继续二分
}
printf("%.4lf\n",mi);
}
return ;
}

最新文章

  1. C#怎样保证弹出窗体是唯一并居中显示
  2. @Transactional 事务管理
  3. 这些年正Android - 母亲
  4. ecshop发票不能使用出现flow.php on line 723等报错
  5. 配置集群Nginx+Memcached+Tomcat集群配置
  6. netstat 命令详解
  7. AngularJs学习笔记4——四大特性之双向数据绑定
  8. Java之面向对象例子(一)
  9. Django REST framework+Vue 打造生鲜超市(四)
  10. Linux关闭You have new mail in /var/spool/mail/root提示
  11. Spring声明式事务配置详解
  12. GUI库之认识Tkinter(一)
  13. 基础业务:滚动到指定位置导航固定(CSS实现)
  14. 持续集成之jenkins2
  15. 7、Docker Container
  16. centos6 命令界面切换到图形界面
  17. redis 学习记录
  18. redhat7搭建本地yum仓库
  19. golang的指针和切片
  20. PHP中查看PHP基本信息

热门文章

  1. InnoDB的Named File Formats
  2. c#dalegate invoke及AsyncCallback使用
  3. owa_outlook暴力破解脚本
  4. C# 给枚举定义DescriptionAttribute,把枚举转换为键值对
  5. IIS8中使用OpenSSL来创建CA并且签发SSL证书
  6. uinty3d使用ugui封装一个分页控件
  7. shrio配置说明
  8. 人工手动冷备不完全恢复介绍(purge表不完全恢复)
  9. line-height属性详解
  10. [河南省ACM省赛-第三届] 网络的可靠性 (nyoj 170)