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 sev-
eral 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
r
i
with 1
r
i
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
.做过啊 二分半径
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <time.h>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const double PI=3.141592653589793;
int T;
double a[];
double l,r,n,f;
bool C(double val)
{
int temp=;
for(int i=;i<=n;i++)
{
temp+=a[i]/val;
}
if(temp>=f)return true;
else return false;
}
int main()
{
cin>>T;
while(T--)
{
cin>>n>>f;
memset(a,,sizeof(a));
for(int i=;i<=n;i++)
{
cin>>a[i];
a[i]=a[i]*a[i]*PI;
r=max(a[i],r);
}
r++;
l=;
f++;
double mid=;
while(r-l>0.000001)
{
mid=(l+r)/;
if(C(mid))l=mid;
else r=mid;
}
if(C(r))printf("%.4lf\n",r);
else printf("%.4lf\n",mid);
}
return ;
}

100722C的更多相关文章

随机推荐

  1. 一个优秀的Unity3d开发者必备的几种设计模式

    Unity脚本编程 众所周知,unity的编程属于脚本化,脚本没有一个具体的概念跟架构, 导致在项目过程中,经常出现哪里需要实现什么功能,就随便添加脚本, 结果,就造成了一片混乱,不好管理. 更有甚者 ...

  2. jsp前三章测试

    (选择一项) A: B: C: D: 正确答案是 B ,B/S架构并不是C/S架构的替代品,有些程序例如大型的网络游戏一般使用的是C/S架构. (选择多项) A: B: C: D: 正确答案是 A,C ...

  3. 关于数组的map、reduce、filter

    map:map()方法定义在Array中,传入自己的参数,就得到一个新的Array作为结果 var aqiData = [ ["北京", 90], ["上海", ...

  4. [No000006]苏格拉底与失恋者的对话

    苏(苏格拉底): 孩子,为什么悲伤? 失(失恋者): 我失恋了. 苏: 哦,这很正常. 如果失恋了没有悲伤,恋爱大概也就没有什么味道了.可是,年轻人,我怎么发现你对失恋的投入甚至比对恋爱的投入还要倾心 ...

  5. js 点击默认另存 ,不是打开 Blob 操作

    function savepic(obj) { if (memFileObj != undefined) { obj = memFileObj; } else { memFileObj = obj; ...

  6. 【BZOJ 1001】[BeiJing2006]狼抓兔子

    Description 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的,而且现在的兔子还比较笨,它们只有两个窝,现在你做为狼王,面对下面这样一个 ...

  7. 【转】Sql Server参数化查询之where in和like实现详解

    转载至:http://www.cnblogs.com/lzrabbit/archive/2012/04/22/2465313.html 文章导读 拼SQL实现where in查询 使用CHARINDE ...

  8. Android 系统稳定性 - ANR(二)(转)

    编写者:李文栋P.S. OpenOffice粘贴过来后格式有些混乱. 1.2 如何分析ANR问题 引起ANR问题的根本原因,总的来说可以归纳为两类: 应用进程自身引起的,例如: 主线程阻塞.挂起.死循 ...

  9. 使用LocalBroadcastManager

    Android中BroadcastReceiver主要用途有 发送通知,更新UI或者数据,应用程序间相互通信,监听系统状态(比如开机,网络等) Android中BroadcasetReceiver的注 ...

  10. Java多线程之Runable与Thread

    Java多线程是Java开发中的基础内容,但是涉及到高并发就有很深的研究可做了. 最近看了下<Java并发实战>,发先有些地方,虽然可以理解,但是自己在应用中很难下手. 所以还是先回顾一下 ...