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. Gvr SDK for Unity 分析(二)

    前言 关于google vr sdk的具体使用,传送门 Gvr SDK for Unity 分析(一) Google Daydream平台已经整合进Google VR SDK 本文环境:Unity5. ...

  2. dp入门问题

    昨天晚上的rank彻底废了..一个星期没敲代码完全没手感.作为总结,贴一道昨天浪费了我两小时的dp.http://acm.dirring.com/problem.php?cid=1003&pi ...

  3. SQL Server的各种聚合函数

    聚合函数是对一组值执行计算并返回单一的值的函数,它经常与SELECT语句的GROUP BY子句一同使用,SQL SERVER 中具体有哪些聚合函数呢?我们来一一看一下: 1. AVG 返回指定组中的平 ...

  4. rqnoj28[stupid]愚蠢的宠物

    题目描述 背景 大家都知道,sheep有两只可爱的宠物(一只叫神牛,一只叫神菜).有一天,sheep带着两只宠物到狗狗家时,这两只可爱的宠物竟然迷路了…… 描述 狗狗的家因为常常遭到猫猫的攻击,所以不 ...

  5. Nginx+keepalived双机热备(主主模式)

    之前已经介绍了Nginx+Keepalived双机热备的主从模式,今天在此基础上说下主主模式的配置. 由之前的配置信息可知:master机器(master-node):103.110.98.14/19 ...

  6. C语言:联合变量

    #include <stdio.h> union hold{ int digit; double big; char letter; }; int main(){ union hold a ...

  7. 启动Oracle

    [oracle@redhat ~]$ su - oracle                                 --“切换到oracle用户”Password:[oracle@redha ...

  8. oracle编程总结

    1,SEQUENCE的使用 问题:在MSSQL中,我们可以通过设置自增长来作为主键,但是oracle里面没有这个 解决方案:使用SEQUENCE来实现,具体步骤如下 (1)首先建立一个序列(就是每次查 ...

  9. 深入运用js

    1,eval()函数 这个函数是获取参数的字符串,并将其作为js来处理,所以这里就有可能有人用这个来搞破坏(比如注入JS脚本文件等),所以最好的是方法是尽量少用,或者可以用new function() ...

  10. 19个必须知道的Visual Studio快捷键(转)

    英文原文:19 Must-Know Visual Studio Keyboard Shortcuts 本文将为大家列出在 Visual Studio 中常用的快捷键,正确熟练地使用快捷键,将大大提高你 ...