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. 高大上的uGUI正式版发布了

    uGUI发布啦 本周期待已久的New UI System 发布了,因为这段时间项目是开发期,所以比较忙,也就没过多关注新UI了,趁着周六日有空,来瞅瞅这高大上的New UI System. PS:我也 ...

  2. java 24 - 2 GUI之监听机制和适配器改进窗口关闭

    我们创建了窗体后,就要对窗体进行操作,比如关闭窗口.而这时候就要建立监听机制: 事件监听机制: A:事件源 事件发生的地方 B:事件 就是要发生的事情 C:事件处理 就是针对发生的事情做出的处理方案 ...

  3. ajax异步举例

    SelectInfo = { release_url: "/compatible/getReleaseFor", project_url: "/compatible/ge ...

  4. TP框架实现分页

    TP框架自带分页的实现方法,所以使用这个分页方案,不用再重新造轮子 1,先看效果图 2,源码 /** * TODO 基础分页的相同代码封装,使前台的代码更少 * @param $m 模型,引用传递 * ...

  5. 背包dp整理

    01背包 动态规划是一种高效的算法.在数学和计算机科学中,是一种将复杂问题的分成多个简单的小问题思想 ---- 分而治之.因此我们使用动态规划的时候,原问题必须是重叠的子问题.运用动态规划设计的算法比 ...

  6. wcf的诡异问题

    最近在做工作流设计器用的silverlight 使用wcf服务. 过程中遇到了两个奇怪的问题. 1. 出现整型参数无法传递到服务器的情况 2.出现反序列化失败的情况. 经过仔细排查发现 每个属性都有一 ...

  7. 我使用celery以及docker部署遇到的问题

    首先我本机测试时没有问题的,但是在线上docker中,任务一直显示 "Sending due task".超时的任务是 django orm update 操作,本地不会出现这样的 ...

  8. 使用Netty绑定一个端口如何分辨出多种类型的DTU的注册包

    一.  背景 项目需要使用Netty和DTU(无线数据传输模块)通信,需要接入多种类型的DTU,每种dtu连接上来之后都首先会发送一个注册报文.需要解析该注册报文来实现: 1. 分辨出是哪种类型的dt ...

  9. Openwrt iptables分析

    这里将载有Openwrt的WR841N的路由表dump出来分析一下. 这个是dump出iptables的命令 root@OpenWrt:/etc/config# iptables-save 这里分为4 ...

  10. C# FTP上传

    public class FtpHelper { public FtpHelper(string p_url, string p_user, string p_password) { if (!p_u ...