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 二分查找
二分查找是一个非常主要的算法,针对的是有序的数列,通过中间值的大小来推断接下来查找的是左半段还是右半段,直到中间值的大小等于要找到的数时或者中间值满足一定的条件就返回,所以当有些问题要求在一定范围内找 ...
随机推荐
- PHPDocumentor安装与使用
phpDocuemtor官网:http://www.phpdoc.org/ 通过pear安装,进入dos的php目录,输入pear install -a PhpDocumentor.如果想使用web接 ...
- android UI之Shape详解_GradientDrawable
在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片. 这样就容易使apk变大. 那 ...
- JS--回到顶部代码
原文地址:http://www.cnblogs.com/liguiqiang1986/articles/3132023.html JS--回到顶部代码 <!DOCTYPE html PUBLIC ...
- jdbc连接数据库工具类
import java.lang.reflect.Field; import java.sql.Connection; import java.sql.DriverManager; import ja ...
- 第06讲- DDMS中logcat的使用
1.DDMS使用 )Device选项卡 Device中罗列了Emulator中所有的进程,选项卡右上角那一排按钮分别为:调试进程.更新进程.更新进程堆栈信息.停止某个进程. )Threads选项卡 ...
- 【强烈推荐】《剑指Offer:名企面试官精讲典型编程题》一书中IT名企经典面试题
各位程序猿: <剑指Offer>一书源自该书作者何海涛坚持更新与编写的博客(http://zhedahht.blog.163.com/),该博客收集整理了大量如微软.Goo ...
- 【转】Linux下socket keep alive讲解
[需求]不影响服务器处理的前提下,检测客户端程序是否被强制终了.[现状]服务器端和客户端的Socket都设定了keepalive属性.服务器端设定了探测次数等参数,客户端.服务器只是打开了keepal ...
- jxl读写excel的方法
jxl 只有excel基本的操作,代码操作比较方便,一般使用jxl就够了,对图片支持较好 poi功能比jxl强大但是比较吃内存,支持计算公式 具体参考链接 http://www.cnblogs. ...
- 模板页 相对路径 JS 加载问题
问题:我在master页面中引入了如下js文件:<script type="text/javascript" src="http://www.cnblogs.com ...
- web并发模型
并发:cpu划分时间片,轮流执行每个请求任务,时间片到期后,换到下一个. 并行:在多核服务器上,每个cpu内核执行一个任务,是真正的并行 IO密集型的应用,由于请求过程中很多时间都是外部IO操作,CP ...