PIE(二分) 分类: 二分查找 2015-06-07 15:46 9人阅读 评论(0) 收藏
Pie |
| Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
| Total Submission(s): 109 Accepted Submission(s): 52 |
|
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 |
|
Sample Output
25.1327 题目大意是要办生日Party,有n个馅饼,有f个朋友,接下来是n个馅饼的半径。然后是分馅饼了, 运用2分搜索: 首先用总饼的体积除以总人数,得到每个人最大可以得到的V,但是每个人手中不能有两片或多片拼成的一块饼, 最多只能有一片分割过得饼。用2分搜索时,把0设为left,把V 设为right。mid=(left+right)/2; 搜索条件是:以mid为标志,如果每块饼都可以分割出一个mid,那么返回true,说明每个人可以得到的饼的体积可以 大于等于mid;如果不能分出这么多的mid,那么返回false,说明每个人可以得到饼的体积小于等于mid。 (1)精度为:0.000001 (2) pi 用反余弦求出,精度更高。 ![]() 1 #include <iostream> ![]() |
PIE(二分) 分类: 二分查找 2015-06-07 15:46 9人阅读 评论(0) 收藏的更多相关文章
- DZY Loves Chemistry 分类: CF 比赛 图论 2015-08-08 15:51 3人阅读 评论(0) 收藏
DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 8大排序算法图文讲解 分类: B10_计算机基础 2014-08-18 15:36 243人阅读 评论(0) 收藏
排序算法可以分为内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存. 常见的内部排序算法有:插入排序.希尔排序. ...
- javascript中0级DOM和2级DOM事件模型浅析 分类: C1_HTML/JS/JQUERY 2014-08-06 15:22 253人阅读 评论(0) 收藏
Javascript程序使用的是事件驱动的设计模式,为一个元素添加事件监听函数,当这个元素的相应事件被触发那么其添加的事件监听函数就被调用: <input type="button&q ...
- XHTML 结构化:使用 XHTML 重构网站 分类: C1_HTML/JS/JQUERY 2014-07-31 15:58 249人阅读 评论(0) 收藏
http://www.w3school.com.cn/xhtml/xhtml_structural_01.asp 我们曾经为本节撰写的标题是:"XHTML : 简单的规则,容易的方针.&qu ...
- Mahout快速入门教程 分类: B10_计算机基础 2015-03-07 16:20 508人阅读 评论(0) 收藏
Mahout 是一个很强大的数据挖掘工具,是一个分布式机器学习算法的集合,包括:被称为Taste的分布式协同过滤的实现.分类.聚类等.Mahout最大的优点就是基于hadoop实现,把很多以前运行于单 ...
- 递归查找无效的符号链接 分类: linux c/c++ 2014-06-02 00:14 345人阅读 评论(0) 收藏
本程序实现在指定目录下递归查找无效的符号链接. 1.设计思路 逐个读取给定目录中的目录项,判断类型 (1)若为目录,则读取该目录中的目录项并判断类型: (2)若为链接文件,则读取出其指向文件的名称(绝 ...
- Squares 分类: POJ 2015-08-04 11:46 3人阅读 评论(0) 收藏
Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 17462 Accepted: 6634 Description ...
- 各种排序算法的分析及java实现 分类: B10_计算机基础 2015-02-03 20:09 186人阅读 评论(0) 收藏
转载自:http://www.cnblogs.com/liuling/p/2013-7-24-01.html 另可参考:http://gengning938.blog.163.com/blog/sta ...
- Ultra-QuickSort 分类: POJ 排序 2015-08-03 15:39 2人阅读 评论(0) 收藏
Ultra-QuickSort Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 48111 Accepted: 17549 ...
随机推荐
- WPF笔记(1.3 属性元素)——Hello,WPF!
原文:WPF笔记(1.3 属性元素)--Hello,WPF! 这一节中“属性元素”的概念可以用匪夷所思形容.1.WPF用标签元素实现对象建模,有两种:Control和Container,都用来装载内容 ...
- 外部样式OL LI的定义 影响到了富文本框内的UL LI的定义,使用内部样式对其还原
<style type="text/css"> #intro { white-space: normal; word-break: break-all; overflo ...
- mongodb导入导出备份恢复
mongodb数据库同样离不开必要的维护,如备份.恢复.导入.导出. 其实备份和恢复比导入和导出要方便些,而且一般不会出错,所以大部分时候使用备份和恢复操作就可以了 1. 备份Mongodb mong ...
- 小KING教你做android项目(一)
写在项目开始之前: 最近关于android的视频教程,入门的书籍也已经有很多了,例如我的入门就是看了mars的视频教程.但是这么一圈学习下来,觉得真正快速提高的,不是在看视频,而是在实际工作中动手做项 ...
- jsp定时方法
jsp定时方法 $(function(){ totaladd(); //定时时触发的函数 setInterval(totaladd,);//设置定时1000=1秒 }); function total ...
- Unity 制作RPG小地图
效果图: 最近公司要制作小地图,搜索网上的文章没找到有什么小实例,=.=直接上步骤: 制作小地图步骤: 1. 人物头顶有一个面板呈现人物图标 2. 有一个摄像机在主角头顶!(Target Textur ...
- Yeslab现任明教教主数据中心第二门课程UCS 视频教程下载
Yeslab现任明教教主数据中心第二门课程UCS 视频教程下载 视频教程目录 Yeslab现任明教教主数据中心第二门课程UCS.1.介绍UCS.rar Yeslab现任明教教主数据中心第二门课程UCS ...
- POJ 2479-Maximum sum(线性dp)
Maximum sum Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 33918 Accepted: 10504 Des ...
- Html5 Css实现方形图片 圆形显示
<!doctype html><html><head><meta charset="utf-8"><title>方形图片 ...
- linux安装chrome
wget http://chrome.richardlloyd.org.uk/install_chrome.sh chmod u+x install_chrome.sh ./install_chrom ...
