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. 在 publicId 和 systemId 之间需要有空格。

    spring  applicationContext_datasource.xml中约束错误 org.springframework.beans.factory.xml.XmlBeanDefiniti ...

  2. 银行卡验证API

    一.银联开放平台 https://open.unionpay.com/tjweb/api/detail?apiSvcId=21 应用场景 综合数据服务平台是银联为接入商户提供的综合数据认证服务接口,目 ...

  3. struts2之标签库

    使用Struts2标签的准备工作: 导入Struts2标签库,该标签定义文件位于 struts2-core-2.3.16.3.jar 的 METE-INF下的struts-tag.tld文件. < ...

  4. lnamp高性能架构之apache和nginx的整合

    搭建过lamp博友和lnmp的博友们可能对这这两个单词并不陌生,对与apachen,nginx相比都源码或yum安装过,但知道apache的nginx的优点,apache处理动态页面很强,nginx处 ...

  5. Linux入门篇(六)——Shell(二)

    这一系列的Linux入门都是本人在<鸟哥的Linux私房菜>的基础上总结的基本内容,主要是记录下自己的学习过程,也方便大家简要的了解 Linux Distribution是Ubuntu而不 ...

  6. phpstorm 安装XeDbug

    第一步:根据phpinfo()下载相对应的Xdebug插件,Xdebug下载路径https://xdebug.org/download.php 第二步:将下载好的Xdebug放到 G:\Service ...

  7. C6748的GPIO口配置使用

    2018年1月17日更新: 这几天用了创龙的C6748的库,对于GPIO配置十分不爽,我移植了RK6748的库,用起来十分酸爽,把下面的文件加入到工程中,然后include头文件后就可以使用.非常好使 ...

  8. 数据分析处理库Pandas——对象操作

    Series结构 索引 修改 旧数据赋值给新数据,旧数据不变. 对某一数值进行修改,可以选择保留修改前或修改后的数值. 替换索引 修改某一个索引 添加 在数据1后添加数据2,数据1不改变. 添加一个数 ...

  9. 笔记-scrapy-去重

    笔记-scrapy-去重 1.      scrapy 去重 scrapy 版本:1.5.0 第一步是要找到去重的代码,scrapy在请求入列前去重,具体源码在scheduler.py: def en ...

  10. java变量、数据类型

    public class Test { public static void main(String[] args) { //变量 //数据类型 变量名; //基本数据类型: //一个字节8位 //整 ...