Pie(hdu 1969 二分查找)
Pie
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7302 Accepted Submission(s): 2732
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
2 1
1000 1000
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define Max 10000+10
#define INF 10000000000
#define P 3.1415926535898
using namespace std;
double a[Max];
int n,f;
int search(double size)
{
int num=;
for(int i=;i<n;i++)
num+=int(a[i]/size);
return num;
}
int main()
{
int T,i,j,e;
freopen("in.txt","r",stdin);
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&f);
f++;
for(i=;i<n;i++)
{
scanf("%d",&e);
a[i]=e*e*P;
}
double mid,l=,r=INF,k;
for(i=;i<;i++)
{
mid=(l+r)/;
if(search(mid)>=f) k=mid,l=mid;
else r=mid;
}
printf("%0.4lf\n",k);
}
}
Pie(hdu 1969 二分查找)的更多相关文章
- hdu 1969(二分)
题意:给了你n个蛋糕,然后分给m+1个人,问每个人所能得到的最大体积的蛋糕,每个人的蛋糕必须是属于同一块蛋糕的! 分析:浮点型二分,二分最后的结果即可,这里要注意圆周率的精度问题! #include& ...
- Equations(hdu 1496 二分查找+各种剪枝)
Equations Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- Can you find it?(hdu 2141 二分查找)
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others ...
- 题解报告:hdu 1969 Pie(二分)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- hdu 2141:Can you find it?(数据结构,二分查找)
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others ...
- hdu 2141 Can you find it?(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141 题目大意:查找是否又满足条件的x值. 这里简单介绍一个小算法,二分查找. /* x^2+6*x- ...
- HDU 4614 线段树+二分查找
Vases and Flowers 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4614 Problem Description Alice is s ...
- hdu 2141 Can you find it?(二分查找变例)
Problem Description Give you three sequences of numbers A, B, C, then we give you a number X. Now yo ...
- 【hoj】2651 pie 二分查找
二分查找是一个非常主要的算法,针对的是有序的数列,通过中间值的大小来推断接下来查找的是左半段还是右半段,直到中间值的大小等于要找到的数时或者中间值满足一定的条件就返回,所以当有些问题要求在一定范围内找 ...
随机推荐
- MVC请求过程 简单分析(一)
在服务端判断客户端传过来的文件的类型,如果是静态文件,直接返回,在页面输出显示.如果是动态文件,通过aspnet_isapi.dll转交过.NetFrameWork框架执行. 创建ISAPIrunti ...
- BZOJ 1565 植物大战僵尸
http://www.lydsy.com/JudgeOnline/problem.php?id=1565 思路:由于植物之间有保护关系:(右边的植物保护左边的植物,植物攻击范围内的植物都被保护了),因 ...
- Thinkpad E430+CentOS 6.4+ linux-3.10.12内核网卡驱动(无线+有线)配置
配置并编译安装内核模块和内核后,解压附件 firmware.tar.bz2,拷贝其中的rtlwifi文件夹到/lib/firmware下,然后 执行装载内核模块命令: sudo modprobe rt ...
- 使用git pull时,项目没有更新?
进入项目目录后,执行 git pull 命令,没有将项目更新,并提示下图: 提示:there is no tracking information for the current branch. 意思 ...
- Azure Storage Client Library 重试策略建议
有关如何配置 Azure Storage Library 重试策略的信息,可参阅 Gaurav Mantri 撰写的一篇不错的文章<SCL 2.0 – 实施重试策略>.但很难找到关于使用何 ...
- java package 重命名时注意事项
如果要对包重命名时,需要关注以下方面: 1. java关联类里的重命名(这个一般通过开发工具会自动修正,如eclipse) 2.配置文件,如原先配置为com.abc,现在更名为com.abc123,这 ...
- bzoj1753 [Usaco2005 qua]Who's in the Middle
Description FJ is surveying his herd to find the most average cow. He wants to know how much milk th ...
- RedHat安装GCC问题-解决依赖问题
RedHat Linux在安装gcc时需要cpp和cloog-ppl但是在安装cpp的时候需要这个依赖:libmpfr.so.1()(64bit) is needed by cpp-4.4.6-3.e ...
- nyoj 234 吃土豆
描述 Bean-eating * grid. Now you want to eat the beans and collect the qualities, but everyone must ob ...
- Hibernate框架增删改查测试类归为一个类
package cn.happy.test; import org.hibernate.Session; import org.hibernate.SessionFactory; import org ...