hdu 1969 Pie (二分法)
Pie
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3133 Accepted Submission(s): 1217
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.
---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.
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2
3.1416
50.2655
//31MS 328K 744 B C++
/* 题意:
开始表示看不懂,后来才知道是给出n块pie,和f+1个人,要求没个人只能拿一块,
可以是完整的一块也可以是不完整的一块。不一定要用上全部的pie。 二分法:
奇葩的题...
假设 x 为每个人在限制条件下能得到的最大的体积的pie,有: s[1]/x+s[2]/x+...+s[n]/x=f+1 //s[i]为第i块pie体积 然后再使用二分法求x,其中low=0,up=max{s[1],s[2],...,s[n]} */
#include<stdio.h>
#include<math.h>
#define eps 1e-7
//#define pi 3.14159265358979323846
#define pi acos(-1.0)
int main(void)
{
int t,n,f;
double s[],r;
scanf("%d",&t);
while(t--)
{
double up=,low=;
scanf("%d%d",&n,&f);
f+=;
for(int i=;i<n;i++){
scanf("%lf",&r);
s[i]=pi*r*r;
if(s[i]>up) up=s[i];
}
double mid=(up+low)/;
while(up-low>eps){
int cnt=;
for(int i=;i<n;i++)
cnt+=(int)(s[i]/mid);
if(cnt>=f) low=mid;
else up=mid;
mid=(up+low)/;
}
printf("%.4lf\n",mid); }
return ;
}
hdu 1969 Pie (二分法)的更多相关文章
- hdu 1969 Pie(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1969 Pie Time Limit: 5000/1000 MS (Java/Others) Me ...
- HDU 1969 Pie(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- HDU 1969 Pie(二分查找)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- HDU 1969(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- HDU 1969 Pie(二分搜索)
题目链接 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pi ...
- HDU 1969 Pie(二分,注意精度)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 1969 Pie【二分】
[分析] “虽然不是求什么最大的最小值(或者反过来)什么的……但还是可以用二分的,因为之前就做过一道小数型二分题(下面等会讲) 考虑二分面积,下界L=0,上界R=∑ni=1nπ∗ri2.对于一个中值x ...
- 题解报告:hdu 1969 Pie(二分)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- hdu 1969 pie 卡精度的二分
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
随机推荐
- Vim---配置实用的.vimrc文件
配置自己电脑的vim,配置一个根据个人习惯使用的.vimrc文件.我的有以下功能等,读者可以根据自己的 个人喜好去配置自己的vim. 1.自动插入文件头 ,新建C.C++源文件时自动插入表头:包括文件 ...
- 1189: [HNOI2007]紧急疏散evacuate
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 3831 Solved: 1119[Submit][Status][Discuss] Descript ...
- 【图论 思维】cf715B. Complete The Graph加强
zzq讲的杂题 题目大意 有一张$n$个点$m$条边的简单正权无向图,$S$到$T$的最短路为$L$,现在有一些边的边权未知,请输出任意一种满足题意的方案. $n,m\le 500000$ ...
- Hibernate无法提取结果集
原因:表结构错误或 与 映射文件不一致 org.springframework.dao.InvalidDataAccessResourceUsageException: could not extra ...
- idea中使用逆向工程----三部曲
逆向工程小伙伴可能都知道,可以根据公司大佬的数据库简单创建实体类和dao接口以及mapper的映射文件,逆向工程可能在数据库字段比较少的时候体现不会方便,但是当参与到数据库字段比较多的时候,我们不可能 ...
- 简单了解,使用oracle中的索引,表分区
索引的分类 如下: 物理分类 逻辑分类 分区或非分区索引 单列或组合索引 B树索引(标准索引) 唯一或非唯一索引 正常或反向键索引 基于函数索引 位图索引 B树索引 b树索引通常也称为标准索引,索 ...
- layer 点击弹出图片
今天做东西有一个功能:在列表点击图片弹出并放大显示,使用到了layer的页面层,下边是个小demo success:function (e) { var url = e.qrcode_url; //a ...
- python--pexpect
大家好,最近工作比较忙,所以没时间来更新博客.趁着还没在下个版本来临之前,来这边再更新更新.是之前学习到的一些老知识点,就当来巩固一下了.开心QAQ 今天给大家介绍的是--Pexpect Expect ...
- cx_freeze的安装使用
python是一个非常非常优秀的编程语言,它最大的特性就是跨平台.python程序几乎可以在所有常见的平台中进行使用,而且大部分无需修改任何代码!不过,python也有一点点小缺憾(这个是由于自身本质 ...
- oauth2.0协议接口-第一篇-api逻辑
开放平台是支持OAuth2.0和RESTful协议的资源分享平台,经过授权的合作伙伴可以读取和写入资讯.用户.文件.数据库等资源. 1.创建数据库表结构 CMSSyncClient(数据同步客户端) ...