HDU1969:Pie(二分)
Pie
Time Limit : 5000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 59 Accepted Submission(s) : 31
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
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 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
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 <iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int t,n,f,i,num,x;
double pi=acos(-1.0); //不能写3.1415926
double l,r,mid;
double s[];
int cmp(double a,double b)
{
return a>b;
}
int main()
{
scanf("%d",&t);
for(;t>;t--)
{
scanf("%d%d",&n,&f);
f++;
double maxn=,sum=;
for(i=;i<=n;i++)
{
scanf("%d",&x);
s[i]=pi*x*x;
maxn=max(maxn,s[i]);
sum=sum+s[i];
}
l=maxn/f;
r=sum/f;
while(l+0.00001<r)
{
mid=(l+r)/;
num=;
for(i=;i<=n;i++) num+=(int)(s[i]/mid);
if (num>=f) l=mid;
if (num<f) r=mid;
}
printf("%.4lf\n",l);
//printf("%lf\n",acos(-1.0));;
}
return ;
}
HDU1969:Pie(二分)的更多相关文章
- HDU 1969 Pie(二分查找)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- Hdu1969 Pie 2017-01-17 13:12 33人阅读 评论(0) 收藏
Pie Time Limit : 5000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submissio ...
- HDU 1969 Pie(二分,注意精度)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- 【POJ 3122】 Pie (二分+贪心)
id=3122">[POJ 3122] Pie 分f个派给n+1(n个朋友和自己)个人 要求每一个人分相同面积 但不能分到超过一个派 即最多把一整个派给某个人 问能平均分的最大面积 二 ...
- Pie(二分)
http://poj.org/problem?id=3122 题意:将n个圆柱体的不同口味的pie分给m个人,要求每个人分得的pie必须体积相同,且来自于一块pie(即:只分得一种口味的pie),求最 ...
- Pie(二分POJ3122)
Pie Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12985 Accepted: 4490 Special Ju ...
- 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 ...
- 【hoj】2651 pie 二分查找
二分查找是一个非常主要的算法,针对的是有序的数列,通过中间值的大小来推断接下来查找的是左半段还是右半段,直到中间值的大小等于要找到的数时或者中间值满足一定的条件就返回,所以当有些问题要求在一定范围内找 ...
- B - Pie (二分)
My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N ...
随机推荐
- Oberon程序设计—目录
内 容前 言1, 什么是Oberon? 1.1 ALGOL家族 1.2 该系统2, 第一:程序 2.1 一个符号来描述的语法: 2.2练习 第一部分,符号和基本类型,分配,控制结构, ...
- Gentoo本地化设置--时区、时钟、字体、中文环境
时区 你需要选择时区让系统知道你的地理位置,以保持正确的时间.在/usr/share/zoneinfo中查找你的时区.然后在/etc/conf.d/clock中设置时区.请忽略/usr/share/z ...
- 【其他】MySql常用命令
Linux下: 登陆命令 mysql -h [hostname] -u [username] -p [password]修改密码 mysqladmin –u[username] –p[oldpwd] ...
- MVC DisplayTemplates and EdiotrTemplates.
我们在mvc项目里经常要对枚举,日期,副文本输入,我们可以用笨拙的方法去view页面里绑定呈现的html内容,而且这种办法不能重用,也就是在不同的view里还是需要做相同的事情,给个日期空间选择例子吧 ...
- webservice 尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下运行,将出现此问题
最近做的项目中,应用服务器迁移到另外一台服务器,操作系统升级为win10,配置好IIS里的应用程序发布网站和Webservice网站后, 客户端程序调用Webservice出错: “尝试加载 Orac ...
- DHCP 协议的 8 种消息类型及功能服务器
1) 主机发送 DHCP Discover 广播包在网络上寻找 DHCP 服务器: 单播数据包, 地址. 2) DHCP 服务器向主机发送 DHCP Offer 单播数据包,包含 IP 地址.MAC ...
- 学习笔记——中介者模式Mediator
中介者模式,A与B之间存在调用对方操作的行为,通过中介者模式,可以去除双方的强引用.如图,A可以通过代理Mediator的方法来调用B的方法,而不需要保存B的引用.
- INI文件的写入与读取
INI文件的写入与读取 [节名] '[]中的节名对应此API的第一参数 Name=内容 'Nmae对应此API的第二参数 API的第三参数是没有取到匹配内容时返回的字符串; ...
- C#未将对象引用设置到对象的实例
未将对象引用设置到对象的实例,这个错误的意思是对象为null,但你还要去取里面的值,所以计算机就不干了.解决办法一般是:用一个你不能确定是不是为null的对象时,尽量做个判断.if(object!=n ...
- centos 命令行 连接无线网卡
ifconfig wlan0 up 1 ifconfig wlan0 iwlist wlan0 scan wpa_passphrase naizhongnai naizhong >> /e ...