Pie
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 12985   Accepted: 4490   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

Northwestern Europe 2006

敲了半天才发现自己理解错题意了QAQ

题意:作者要开一个生日party,他现在拥有n块高度都为1的圆柱形奶酪,已知每块奶酪的底面半径为r不等,作者邀请了f个朋友参加了他的party,他要把这些奶酪平均分给所有的朋友和他自己(f+1人),每个人分得奶酪的体积必须相等(这个值是确定的),形状就没有要求。现在要你求出所有人都能够得到的最大块奶酪的体积是多少?

#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const double Pi = 3.1415926535897932;
const double eps = 1e-5;
int n,m;
double Arr[11000];
bool Judge(double s)
{
int ans=0;
for(int i=1; i<=n; i++)
{ ans+=(int)(Arr[i]/s);
if(ans>=m+1)
{
return true;
}
}
return false;
}
int main()
{
int T;
double r;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&n,&m);
double L=0,R=0;
for(int i=1; i<=n; i++)
{
scanf("%lf",&r);
Arr[i]=r*r*Pi;
R+=Arr[i];
}
double ans=0;
while(R-L>eps)
{
double mid=(L+R)/2;
if(Judge(mid))
{
ans=mid;
L=mid;
}
else
{
R=mid;
}
}
printf("%.4f\n",ans);
}
return 0;
}

Pie(二分POJ3122)的更多相关文章

  1. poj3122 Pie (二分)

    题目链接:https://vjudge.net/problem/POJ-3122 题意:有n块饼,m+1个人,将饼均分成m+1块,求每块最大的大小. 思路:水二分,显然每块的大小与可以给多少人吃具有单 ...

  2. HDU 1969 Pie(二分查找)

    Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...

  3. HDU 1969 Pie(二分,注意精度)

    Pie Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

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

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

  5. Pie(二分)

    http://poj.org/problem?id=3122 题意:将n个圆柱体的不同口味的pie分给m个人,要求每个人分得的pie必须体积相同,且来自于一块pie(即:只分得一种口味的pie),求最 ...

  6. PIE(二分) 分类: 二分查找 2015-06-07 15:46 9人阅读 评论(0) 收藏

    Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  7. 【hoj】2651 pie 二分查找

    二分查找是一个非常主要的算法,针对的是有序的数列,通过中间值的大小来推断接下来查找的是左半段还是右半段,直到中间值的大小等于要找到的数时或者中间值满足一定的条件就返回,所以当有些问题要求在一定范围内找 ...

  8. HDU1969:Pie(二分)

    Pie Time Limit : 5000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submissio ...

  9. B - Pie (二分)

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

随机推荐

  1. Silverlight验证相关

    asp.net mvc中有验证,当然在silverlight中也包含有验证规则的但这个就离不开mvvm(其实就是实体层,页面这些东西的组成,没有用过呀,悲哀!连这个概念都理解不了). 关于MVVM验证 ...

  2. powershell 参数 [String]Service

    此种情况,去掉前面的[String] 在里面操作的时候就会认为是string,并可以自动操作了,否则限定为String类型时,就无法将输入的a,b当作String了, 或者需要添加'a,b'单引号来变 ...

  3. ASP.NET的一般处理程序对数据的基本操作

    TableList.ashx: <%@ WebHandler Language="C#" Class="TableList" %> using Sy ...

  4. [转]jQueryEasyUI Messager基本使用

    一.jQueryEasyUI下载地址 http://www.jeasyui.com/ 二.jQueryEasyUI Messager基本使用 1.$.messager.alert(title, msg ...

  5. Sping中的事务配置

    关于Spring的事务配置,主要的配置文件如下(使用了C3P0连接池): <?xml version="1.0" encoding="UTF-8"?> ...

  6. HDU 4833 Best Financing(DP)(2014年百度之星程序设计大赛 - 初赛(第二轮))

    Problem Description 小A想通过合理投资银行理财产品达到收益最大化.已知小A在未来一段时间中的收入情况,描述为两个长度为n的整数数组dates和earnings,表示在第dates[ ...

  7. xsd与xsl文件的区别

    请问xsd与xsl文件的区别在哪里呢?   我刚学xml,一开始用xmlspy学的,然后生成了一个xsd的文件,但在网上下的源程序是有一个xsl文件的,很不明之间有什么区别的,为什么别人的程序不用xs ...

  8. Linux mail 命令参数

    linux mail 命令参数: 使用mail发邮件时,必须先将sendmail服务启动. mail –s “邮件主题” –c”抄送地址” –b “密送地址” -- -f 发送人邮件地址 –F 发件人 ...

  9. oracle ebs request一直pending

    如果提交请求以后,状态一直是pending状态,可以在“工具”打开“Manager”,查看一下Maximum是否有设置错,另外pending的数量当前是多少. 如果Maximum是1,pending是 ...

  10. opencv之深拷贝及浅拷贝,IplImage装换为Mat

    一.(1)  浅拷贝: Mat B; B = image  // 第一种方式 Mat C(image); // 第二种方式 这两种方式称为浅copy,是由于它们有不同的矩阵头,但是它们共享内存空间,即 ...