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. java TCP通信 socket 套接字 用图片上传轰炸服务器

    客户端 package com.swift.jinji; import java.io.FileInputStream; import java.io.IOException; import java ...

  2. 在xampp修改密码

    1.选择 服务器--账号--修改密码 2.在密码 一栏输入新密码 3.刷新页面会得到如下页面 此时,该页面提醒我们检查配置文件中的主机.用户名和密码 4.打开配置文件 路径为 xampp -> ...

  3. Javascript和HTML5的关系

    HTML5是一种新的技术,就目前而言,我们所知的HTML5都是一些标签,但是有了JS之后,这些标签深层的扩展功能才得以实现.       比如video标签,我们对其理解为一个简单的标签,但实际上,v ...

  4. hdu_1452_Happy 2004 (乘法逆元

    Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your ...

  5. 利用sysbench进行MySQL OLTP基准测试

      Preface       In order to know clearly about the real performance threshold of database server,we ...

  6. zabbix运维监控平台

    zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位/解决 ...

  7. jquery 配合 ajax 完成 在线编辑 你值得拥有

    思路分析: 将 table中的表格 改变成为 input表格框获得值 ajax配合修改 删除 <?php use yii\helpers\Url; $web = Url::base(); ?&g ...

  8. jupyter notebook中出现ValueError: signal only works in main thread 报错 即 长时间in[*] 解决办法

    我在jupyter notebook中新建了一个基于py3.6的kernel用来进行tensorflow学习 但是在jupyter notebook中建立该kernel时,右上角总是显示 服务正在启动 ...

  9. python flask学习第2天 URL中两种方式传参

    新创建项目   自己写个url映射到自定义的视图函数 在url中传递参数 app.py from flask import Flask app = Flask(__name__) @app.route ...

  10. SPOJ1026 概率DP

    Favorite Dice BuggyD loves to carry his favorite die around. Perhaps you wonder why it's his favorit ...