博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电1969--Pie(二分法)
阅读量:7138 次
发布时间:2019-06-28

本文共 2688 字,大约阅读时间需要 8 分钟。

Pie

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 6442    Accepted Submission(s): 2421

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:            
RE: 给出的是食物半径+(认真读题)
1 #include 
2 #include
3 #include
4 #define PI acos(-1.0) 5 //#define PI 3.1415926 不要用这个; 6 using namespace std; 7 double num[10010]; 8 int main() 9 {10 int t;11 scanf("%d", &t);12 while(t--)13 {14 int m, n;15 double max = 0.0;16 scanf("%d %d", &m, &n);17 n++;18 for(int i=0; i
max)24 max = num[i];25 }26 double min=0.0, mid;27 while(max - min > 1e-6)28 {29 mid=(max + min) / 2.0;30 int total = 0;31 for(int i=0; i
= n)34 min = mid;35 else36 max = mid;37 }38 printf("%.4lf\n",mid);39 }40 return 0; 41 }

 

 

转载于:https://www.cnblogs.com/soTired/p/4699077.html

你可能感兴趣的文章
深入理解Linux内核-内核同步
查看>>
zabbix实现mysql数据库的监控(三)
查看>>
外观模式-多了个办事处
查看>>
laravel 文件上传
查看>>
《寻路算法第二篇》A*寻路的路径平滑、静态合并、生成格子工具自动化、
查看>>
求职防骗指南
查看>>
23命令模式Command
查看>>
Cortex系列M0-4简单对比
查看>>
相对定位
查看>>
JAVASCRIPT 类型转换
查看>>
SQL优化-标量子查询(数据仓库设计的隐患-标量子查询)
查看>>
java 拷贝功能
查看>>
ZOJ2432 Greatest Common Increasing Subsequence 题解报告
查看>>
Cannot find module `express`
查看>>
20051206: 早退
查看>>
凸包问题的描述(Graham法)
查看>>
JavaScript严格模式总结
查看>>
07-图
查看>>
20145127《java程序设计》第四周学习总结
查看>>
idea中,使用facets添加完web后,项目已变为web项目,但web.xml中内容经常变为红色,并报错,如何解决?...
查看>>