Pie

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6320    Accepted Submission(s):
2383

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
 
题解:求自己和朋友可以分得的最大馅饼面积
#include<stdio.h>
#include<string.h>
#include<math.h>
#define MAX 10100
#define pi 3.1415926
double a[MAX];
int n,m;
int f(double x)
{
int i,s=0;
for(i=0;i<n;i++)
s+=(int)(a[i]/x);
return s;
}
int main()
{
int j,i,t;
double max,k;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%lf",&k);
a[i]=k*k*pi;
}
double l=0,r=200000000000.0,mid;
while(r - l > 1e-6)
{
mid = (r + l)/2;
if(f(mid) >= m+1)//算上自己
l=mid;
else
r=mid;
}
printf("%.4lf\n",r);
}
return 0;
}

  

hdoj 1969 Pie【二分】的更多相关文章

  1. HDU 1969 Pie(二分查找)

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

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

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

  3. HDU 1969 Pie [二分]

    1.题意:一项分圆饼的任务,一堆圆饼共有N个,半径不同,厚度一样,要分给F+1个人.要求每个人分的一样多,圆饼允许切但是不允许拼接,也就是每个人拿到的最多是一个完整饼,或者一个被切掉一部分的饼,要求你 ...

  4. (step4.1.2)hdu 1969(Pie——二分查找)

    题目大意:n块馅饼分给m+1个人,每个人的馅饼必须是整块的,不能拼接,求最大的. 解题思路: 1)用总饼的体积除以总人数,得到每个人最大可以得到的V.但是每个人手中不能有两片或多片拼成的一块饼. 代码 ...

  5. hdu 1969 Pie(二分查找)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1969 Pie Time Limit: 5000/1000 MS (Java/Others)    Me ...

  6. HDU 1969 Pie【二分】

    [分析] “虽然不是求什么最大的最小值(或者反过来)什么的……但还是可以用二分的,因为之前就做过一道小数型二分题(下面等会讲) 考虑二分面积,下界L=0,上界R=∑ni=1nπ∗ri2.对于一个中值x ...

  7. 题解报告:hdu 1969 Pie(二分)

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

  8. hdu 1969 pie 卡精度的二分

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

  9. 【HDOJ】1969 Pie

    二分. #include <stdio.h> #include <math.h> ; ]; int main() { int case_n, n, f, m; double r ...

随机推荐

  1. Action<>和Func<>区别

    Action<>和Func<>其实都是委托的[代理]简写形式. 简单的委托写法: //普通的委托 public delegate void myDelegate(string ...

  2. 环状DNA序列

    大意: 一个DNA序列是环状的,这意味着有N个碱基的序列有N种表示方法(假设无重复).而这N个序列有一种最小的表示,这个最小表示的意思是这个序列的字典序最小(字典序的意思是在字典中的大小 比如ABC& ...

  3. 《Velocity java开发指南》中文版(下)转载

    文章出自:http://sakyone.iteye.com/blog/524292 8.Application Attributes Application Attributes (应用程序属性)是和 ...

  4. linux vim 基本操作

    (一定要在英文输入法的状态下才有效)vi:实际上linux 上的 vi 不是真正的 vi,而是 vim;纯的 vi只在某些 unix 系统上还存在纯 的vi里面不支持退格键盘了,当按退格键盘以后,不是 ...

  5. myeclipse 项目运行时报错:运行项目时报错:Could not publish server configuration for Tomcat v6.0 Server at localhost. Multiple Contexts have a"/"

    1.先去E:\PLZT\workspace\.metadata\.plugins\org.eclipse.wst.server.core.sever.xml看里面是否存在两个配置是的话删除一个重启服务 ...

  6. qrcode.js插件将你的内容转换成二维码格式

    ---qrcode.js插件将你的内容转换成二维码格式--- 我之前一直想知道二维码是怎么生成,所以就了解了一下, 最后还是不知道它的原理, 但是,我知道怎么生成. 现在就让我带你制作一个你喜爱的二维 ...

  7. 《JavaScript高级程序设计 第3版》-学习笔记-3

    P84-P137页, 这一章看的真久,这个月事太多了.有些内容在代码注释里没提出来了 1.JS强大的数组类型,元素类型任意,提供了非常多的操作数组的方法和属性 /* 数组类型 */ //stack v ...

  8. favicon.ico的使用方法

    favicon.ico怎么来,就自己决定了. 虽说是放在网站根目录下就行了, 但最好是放在网站images目录下,方便统一管理. 然后在head.tpl.php 中的<head></ ...

  9. 从文章"避免复制与粘贴"到文章"Extract Method"的反思(3)

    在牛人的博客中提到了..如果你的代码可以copy-past的时候,那么久证明你的代码出现了重复.而这种重复仅仅是虚假的代码行的增加而不是像其他的代码复用那样降级成本. copy-pase代码意味着你违 ...

  10. IOS Quartz 各种绘制图形用法---实现画图片、写文字、画线、椭圆、矩形、棱形等

    // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affec ...