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. Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction policies

    Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction pol ...

  2. C# 之【获取网页响应码200】

    做了个监控网站的C#项目,判断网站是否运行正常,采用的就是获取HTTP头返回的状态码. 比如状态码为200的就是网站正常,403是Forbidden,404是网页未找到这样. 代码如下: 首先是使用库 ...

  3. MVVM模式应用 之为ApplicationBarIconButton 添加Command操作属性

    在学习MVVM的过程中,总是会遇到挫折,一碰到就是花费好长时间去解决..唉,不求量,只求质. 第一种(已经实践成功): (1)http://bindableapplicationb.codeplex. ...

  4. JavaScript拖拽

    <!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-e ...

  5. JavaScript 学习笔记之线程异步模型

    核心的javascript程序语言并没有包含任何的线程机制,客户端javascript程序也没有任何关于线程的定义,事件驱动模式下的javascript语言并不能实现同时执行,即不能同时执行两个及以上 ...

  6. .net中String是引用类型还是值类型 以及 C#深层拷贝浅层拷贝

    http://www.cnblogs.com/yank/archive/2011/10/24/2204145.html http://www.cnblogs.com/zwq194/archive/20 ...

  7. C#让程序自动在管理员权限下运行

    windows 7和vista提高的系统的安全性,同时需要明确指定“以管理员身份运行”才可赋予被运行软件比较高级的权限,比如访问注册表等.否则,当以普通身份运行的程序需要访问较高级的系统资源时,将会抛 ...

  8. sublime3快捷键汇总

    !+tab生成html结构文档选择类 Ctrl+D 选中光标所占的文本,继续操作则会选中下一个相同的文本.Alt+F3 选中文本按下快捷键,即可一次性选择全部的相同文本进行同时编辑.举个栗子: 快速选 ...

  9. ios7新特性3-Map Kit新特性

    Map Kit 框架 (MapKit.framework) 包含了大量的改进以及为基于地图的程序提供了新特性.利用地图显示位置信息的应用现在可以使用Maps这个程序用到的3D地图,包括控制程序控制视线 ...

  10. 解决File.delete()删除不掉文件

    首先注意两点: 此文件被使用的时候无法删除(比如网络输出没关闭流) 判断此文件是否存在再做删除(exists) 删除文件夹之前先删除文件夹下的所有文件(递归解决) 判断是否删除成功会有返回值,文件名错 ...