PIE(二分)
2015-06-07 15:46
375 查看
Pie |
TimeLimit:5000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others) |
TotalSubmission(s):109AcceptedSubmission(s):52 |
ProblemDescription MybirthdayiscomingupandtraditionallyI'mservingpie.Notjustonepie,no,IhaveanumberNofthem,ofvarioustastesandofvarioussizes.Fofmyfriendsarecomingtomypartyandeachofthem getsapieceofpie.Thisshouldbeonepieceofonepie,notseveralsmallpiecessincethatlooksmessy.Thispiececanbeonewholepiethough. Myfriendsareveryannoyingandifoneofthemgetsabiggerpiecethantheothers,theystartcomplaining.Thereforeallofthemshouldgetequallysized(butnotnecessarilyequallyshaped)pieces,evenifthisleadstosome piegettingspoiled(whichisbetterthanspoilingtheparty).Ofcourse,Iwantapieceofpieformyselftoo,andthatpieceshouldalsobeofthesamesize. Whatisthelargestpossiblepiecesizeallofuscanget?Allthepiesarecylindricalinshapeandtheyallhavethesameheight1,buttheradiiofthepiescanbedifferent. |
Input Onelinewithapositiveinteger:thenumberoftestcases.Thenforeachtestcase: ---OnelinewithtwointegersNandFwith1<=N,F<=10000:thenumberofpiesandthenumberoffriends. ---OnelinewithNintegersriwith1<=ri<=10000:theradiiofthepies. |
Output Foreachtestcase,outputonelinewiththelargestpossiblevolumeVsuchthatmeandmyfriendscanallgetapiepieceofsizeV.Theanswershouldbegivenasafloatingpointnumberwithanabsolute errorofatmost10^(-3). |
SampleInput3 33 433 124 5 105 1423456542 |
SampleOutput25.1327 3.1416 50.2655 题目大意是要办生日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> |
相关文章推荐
- spring jdbctemplate源码跟踪
- Mysql 慢查询和慢查询日志分析
- Android Dialog 应用
- redis实现关系型数据库连接查询
- erlang VM全局内存分布
- JavaBean
- linux高级编程基础系列:线程间通信
- 团队作业:设计类图—飞机大战
- iis8 默认不支持svc解决方法
- redis安装及常用命令
- c++在string类源
- 1.1 Core JavaScript(continued)
- LeetCode题解(20)--Valid Parentheses
- 东方之星
- 双树 节点 C# net Ztree linqtosql 源码
- akoj-1076-Encoding
- 【整理】二叉树概念以及代码实现
- Objective C 中的nil,Nil,NULL和NSNull理解
- XTHML
- 十三周——输入输出流——项目— 小玩文件(1)