Pie

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3133    Accepted Submission(s): 1217

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
 
Recommend
wangye   |   We have carefully selected several similar problems for you:  1551 2446 2298 2333 1399 
 
 //31MS    328K    744 B    C++
/* 题意:
开始表示看不懂,后来才知道是给出n块pie,和f+1个人,要求没个人只能拿一块,
可以是完整的一块也可以是不完整的一块。不一定要用上全部的pie。 二分法:
奇葩的题...
假设 x 为每个人在限制条件下能得到的最大的体积的pie,有: s[1]/x+s[2]/x+...+s[n]/x=f+1 //s[i]为第i块pie体积 然后再使用二分法求x,其中low=0,up=max{s[1],s[2],...,s[n]} */
#include<stdio.h>
#include<math.h>
#define eps 1e-7
//#define pi 3.14159265358979323846
#define pi acos(-1.0)
int main(void)
{
int t,n,f;
double s[],r;
scanf("%d",&t);
while(t--)
{
double up=,low=;
scanf("%d%d",&n,&f);
f+=;
for(int i=;i<n;i++){
scanf("%lf",&r);
s[i]=pi*r*r;
if(s[i]>up) up=s[i];
}
double mid=(up+low)/;
while(up-low>eps){
int cnt=;
for(int i=;i<n;i++)
cnt+=(int)(s[i]/mid);
if(cnt>=f) low=mid;
else up=mid;
mid=(up+low)/;
}
printf("%.4lf\n",mid); }
return ;
}

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

  1. hdu 1969 Pie(二分查找)

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

  2. HDU 1969 Pie(二分法)

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

  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. 交换机基础设置之vtp管理vlan设置

    vtp的设置有三种模式1:server模式,负责创建,删除vlan(服务器模式) 2:client模式,负责接收并转发来自server的信息(客户机模式) 3:transparent模式,只负责转发, ...

  2. scrapy--多爬虫

    大家好,我胡汉三又回来了!!!开心QAQ 由于最近一直在忙工作的事,之前学的一些爬虫知识忘得差不多了,只能再花多一些时间来回顾,否则根本无法前进.所以在这里也像高中老师那样提醒一下大家,--每天晚上花 ...

  3. 环形缓冲区实现类(Delphi)

    环形缓冲区的用途及原理可以去百度资料狠多的,这里就不介绍了.直接贴代码.代码分别用D7,XE2编译测试 源码下载 http://files.cnblogs.com/lwm8246/uCircleBuf ...

  4. 虚拟机linux桥接联网问题

    Linux系统为redhat5.8 虚拟机的版本:vm8.0 本人刚刚开始接触linux,今日需要通过linux进行联网,因此也学习了一点点关于虚拟机的联网的知识,在此与大家进行分享,希望大家可以之处 ...

  5. <jsp:param>传参乱码问题

    在添加参数的界面添加<%request.setCharacterEncoding("UTF-8");%> 实例代码: login_confirm.jsp <%@ ...

  6. Android 懒加载简单介绍

    1.懒加载介绍 1.1.效果预览 1.2.效果讲解 当页面可见的时候,才加载当前页面. 没有打开的页面,就不会预加载. 说白了,懒加载就是可见的时候才去请求数据. 1.3.懒加载文章传送门 参考文章: ...

  7. 十一、mysql老是停止运行该怎么解决

    mysql老是停止运行该怎么解决 你可能还会遇到无法启动mysql的错误 解决方法如下:      

  8. NPM安装vue-cli,并创建vue+webpack项目模板

    1.安装npm npm 是node.js 的包管理工具, 安装流程地址:https://docs.npmjs.com/cli/install  估计会非常慢,我们可以使用淘宝NPM镜像下载安装:htt ...

  9. android gradle.properties

    gradle.properties 里面配置的东西,在gradle 文件里面可以直接引用. 例如: 在你工程根目录的gradle.properties 文件里面 可以这样配置: ## Project- ...

  10. netty学习记录1

    最近在学习netty,看的是<netty权威指南 第2版>. 然后看的同时也把书上面的代码一行行敲下来做练习,不过到第三章就出问题了. 按照书上讲的,sever/client端都需要继承C ...