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. u3d_Shader_effects笔记5 第二章 通过UV,进行纹理移动

    1.前面心情 公司最近打包,像我等小弟闲着,看代码容易困,没事偷着学shader,不过还是要多交流才行. 2.本文参考 这次参考比较多:由texture uv延伸问题多,主要是不明白变量定义: htt ...

  2. Kali linux渗透测试常用工具汇总2-渗透攻击

    渗透攻击的思路一般是扫描漏洞,然后利用不同的漏洞,才有针对的渗透攻击. 漏洞扫描的工具有Nessus,该工具可同时在本地或远端遥控,对系统的漏洞分析扫描.Nessus通过新建扫描策略,并添加对应的插件 ...

  3. SQL使用开窗函数与CTE查询每月销售额的前几名

    WITH tagTab AS( SELECT YearMonth, pm=RANK() OVER(PARTITION BY YearMonth ORDER BY amount DESC) FROM S ...

  4. listview+seekbar问题的解决

    最近做了个项目,其中有录音播放功能.每次录音结束都会在listView中显示,在listView中能播放每次的录音,也可以每条录音之间的切换播放.随之就引发了许多的问题,比如当我播放第一条录音的时所有 ...

  5. git 找回丢失的commit

    From : http://dmouse.iteye.com/blog/1797267 git 的错误操作,导致丢失了重要的commit,真是痛不欲生: 最后通过git神器终于找回了丢失的commit ...

  6. MVC3中常用的一些控件及方法

    1.返回提示框 string script = String.Format("<script>alert('登录状态已失效! 请重新登录系统');location.href='{ ...

  7. Theano2.1.14-基础知识之理解为了速度和正确性的内存别名

    来自:http://deeplearning.net/software/theano/tutorial/aliasing.html Understanding Memory Aliasing for ...

  8. 用 Smarty 生成静态页面入门介绍

    why Smarty? 随着公司首页(以下简称首页)流量越来越大,最近开始考虑使用后台语言生成静态页面的技术. 我们知道,一个简单页面一般是一个 .html(或者 .htm ..shtml)后缀的文件 ...

  9. c/s 自动升级(WebService)

    首先声明,本人文笔不好,大家见笑,欢迎高手吐槽. 做c/s开发肯定会遇到的就是自动升级功能,而这实现方式是非常多. 本文使用 webservice的方式来提供升级服务 首先准备服务 为了方便我们专门用 ...

  10. [BZOJ2730][HNOI2012]矿场搭建(求割点)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2730 分析: 如果坍塌的点不是割点,那没什么影响,主要考虑坍塌的点是割点的情况. 显然 ...