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. 深入探讨 java.lang.ref 包

    深入探讨 java.lang.ref 包 本文主要探讨了 java.lang.ref 包的使用方法,以及源码解读.并就该包在不同 JVM 上的表现进行了比较与分析.通过阅读本文,读者可以加深对 jav ...

  2. LFI漏洞利用总结

    主要涉及到的函数 include(),require().include_once(),require_once() magic_quotes_gpc().allow_url_fopen().allo ...

  3. MongoDB集群架构及搭建

    MongoDB分布式集群 MongDB分布式集群能够对数据进行备份,提高数据安全性,以及提高集群提高读写服务的能力和数据存储能力.主要通过副本集(replica)对数据进行备份,通过分片(shardi ...

  4. Kafka是分布式发布-订阅消息系统

    Kafka是分布式发布-订阅消息系统 https://www.biaodianfu.com/kafka.html Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apa ...

  5. Android 中的 Service 全面总结

    1.Service的种类   按运行地点分类: 类别 区别  优点 缺点   应用 本地服务(Local) 该服务依附在主进程上,  服务依附在主进程上而不是独立的进程,这样在一定程度上节约了资源,另 ...

  6. QT TCP文件上传服务器

    利用QT做为client端,纯C语言做为server端,利用tcp协议,实现client端向server端传递文件 Linux服务器端 //头文件 #include <stdio.h> # ...

  7. scala + intellij idea 环境搭建及编译、打包

    大数据生态圈中风头正旺的Spark项目完全是采用Scala语言开发的,不懂Scala的话,基本上就没法玩下去了.Scala与Java编译后的class均可以运行于JVM之上,就好象.NET中F#与C# ...

  8. Apache Shiro 使用手册(一)Shiro架构介绍 - kdboy - ITeye技术网站

    转载 原文地址 http://kdboy.iteye.com/blog/1154644 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理 ...

  9. 安装包制作工具 SetupFactory使用1 详解

    2014-11-19 Setup Factory 是一个强大的安装程序制作工具.提供了安装制作向导界面,即使你对安装制作不了解,也可以生成专业性质的安装程序.可建立快捷方式,也可直接在 Windows ...

  10. Qt 学习笔记 TreeWidget 增删改

    在窗体上放一个TreeWidget控件和四个PushButton加一个Horizontal Spacer 布局如图 给树添加元素节点的方法和实现 .h文件 QTreeWidgetItem * AddT ...