Pie
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 13564   Accepted: 4650   Special Judge

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

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<iomanip>
#include<queue>
#include<stack>
using namespace std;
#define N 10000
#define PI 3.1415926535897932384626
double r[N],v,d,c,ma;
int main(){
//freopen("in.txt","r",stdin);
std::ios::sync_with_stdio(false);
cin>>c;
while(c--){
int n,f;
cin>>n>>f;
f++;
ma=0.0;
for(int i=;i<n;i++){
cin>>r[i];
r[i]*=r[i];
if(ma<r[i]) ma=r[i];
}
double up,low,mid;
low=0.0;up=ma;
while(up-low>1e-){
mid=(up+low)/;
int num=;
for(int i=;i<n;i++)
num+=(int)(r[i]/mid);
if(num>=f)
low=mid;
else
up=mid;
}
cout<<fixed<<setprecision()<<mid*PI<<endl;
}
return ;
}

poj 3122(二分查找)的更多相关文章

  1. POJ 3122 二分

    大致题意: 就是公平地分披萨pie 我生日,买了n个pie,找来f个朋友,那么总人数共f+1人 每个pie都是高为1的圆柱体,输入这n个pie的每一个尺寸(半径),如果要公平地把pie分给每一个人(就 ...

  2. 【POJ】3122 Pie [二分查找]

    题目地址:http://poj.org/problem?id=3122 二分每块饼的体积.为了保证精度,可以先二分半径的平方r*r,最后再乘以PI.要注意一点,要分的人数要包括自己,及f+1. #in ...

  3. POJ 3273 Monthly Expense(二分查找+边界条件)

    POJ 3273 Monthly Expense 此题与POJ3258有点类似,一开始把判断条件写错了,wa了两次,二分查找可以有以下两种: ){ mid=(lb+ub)/; if(C(mid)< ...

  4. POJ 1064 Cable master(二分查找+精度)(神坑题)

    POJ 1064 Cable master 一开始把 int C(double x) 里面写成了  int C(int x) ,莫名奇妙竟然过了样例,交了以后直接就wa. 后来发现又把二分查找的判断条 ...

  5. POJ 3122 & 3258 & 3273 #二分

    以下三道都是经典二分,道理都差不多,代码就贴在一起了. POJ 3122    POJ 3258    POJ 3273 POJ 3122: #include<iostream> #inc ...

  6. poj 2452(RMQ+二分查找)

    题目链接: http://poj.org/problem?id=2452 题意:在区间[1,n]上找到满足 a[i]<a[k]<a[j] (i<=k<=j) 的最大子区间 (j ...

  7. 【POJ 3122】 Pie (二分+贪心)

    id=3122">[POJ 3122] Pie 分f个派给n+1(n个朋友和自己)个人 要求每一个人分相同面积 但不能分到超过一个派 即最多把一整个派给某个人 问能平均分的最大面积 二 ...

  8. POJ 3273 Monthly Expense二分查找[最小化最大值问题]

    POJ 3273 Monthly Expense二分查找(最大值最小化问题) 题目:Monthly Expense Description Farmer John is an astounding a ...

  9. POJ——3061Subsequence(尺取法或二分查找)

    Subsequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11224   Accepted: 4660 Desc ...

  10. POJ 2182 Lost Cows (树状数组 && 二分查找)

    题意:给出数n, 代表有多少头牛, 这些牛的编号为1~n, 再给出含有n-1个数的序列, 每个序列的数 ai 代表前面还有多少头比 ai 编号要小的牛, 叫你根据上述信息还原出原始的牛的编号序列 分析 ...

随机推荐

  1. redis.conf详细说明

    daemonize yes #---默认值no,该参数用于定制redis服务是否以守护模式运行.--- pidfile /var/run/redis.pid #默认值/var/run/redis.pi ...

  2. Robot Framework Chrome

    1. 下载对应版本的chromedriver, 好像都是windows32位的,不过没关系,可以用即可. 2. 将chromedriver放入到chrome的安装路径下,然后将chromrdriver ...

  3. 【bzoj】1927 [Sdoi2010]星际竞速

    [算法]最小费用最大流 [题解]跟滑雪略有类似,同样因为可以重复所以不是最小路径覆盖. 连向汇的边容量为1足矣,因为一个点只会出去一次(路径结束). bzoj 1927 [Sdoi2010]星际竞速 ...

  4. FZUOJ 2205 据说题目很水 (无三元环图最大边数)

    Problem Description Sunday最近对图论特别感兴趣,什么欧拉回路什么哈密顿回路,又是环又是树.在看完一本书后,他对自己特别有信心,便找到大牛牛犇犇,希望他出一题来考考自己. 在遥 ...

  5. 常见网络命令之Ping命令

    前言:计算机网络老师要求我们自己总结一下常见的网络命,然后上课可以上去讲一下这些命令使用,像我这么听话的好学生,肯定是照老师要求,认真的总结了一下,总结的过程中,我发现网上已经有的资源讲的都不是很详细 ...

  6. 《Linux内核原理与设计》第十一周作业 ShellShock攻击实验

    <Linux内核原理与设计>第十一周作业 ShellShock攻击实验 分组: 和20179215袁琳完成实验及博客攥写 实验内容:   Bash中发现了一个严重漏洞shellshock, ...

  7. python基础===Sublime Text 3 快捷键

    选择类 Ctrl+D 选中光标所占的文本,继续操作则会选中下一个相同的文本. Alt+F3 选中文本按下快捷键,即可一次性选择全部的相同文本进行同时编辑.举个栗子:快速选中并更改所有相同的变量名.函数 ...

  8. C后端设计开发 - 第5章-内功-数据结构下卷

    正文 第5章-内功-数据结构下卷 后记 如果有错误, 欢迎指正. 有好的补充, 和疑问欢迎交流, 一块提高. 在此谢谢大家了.

  9. 如何使用vux创建vue项目

    1.安装vue-cli,通过vue-v可以查明 安装vue-cli步骤 vue init airyland/vux2 projectPath(项目名字) 2.安装依赖模块 方法1:npm instal ...

  10. Mysql 数据库学习笔记01查询

    1.数据查询基本操作 * 正则表达式查询: 字段名 regexp '匹配方式', select * from user where username regexp '^名'    -- 查询 姓名 名 ...