简单的二分法应用,循环1000次精度就满足要求了。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
#define LL long long int
const double eps=1e-;
const int INF=;
const int maxn=+;
const double pi=acos(-);
int N,F,T;
double r[maxn],maxr,s[maxn];
bool ok(double x)
{
int f=;
for(int i=;i<N;i++)
{
f+=(int)(s[i]/x);
if(f>=F) return true;
}
return false;
}
int main()
{
//freopen("in1.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&N,&F);
maxr=-;
F++;
for(int i=; i<N; i++)
{
scanf("%lf",&r[i]);
maxr=max(r[i],maxr);
s[i]=r[i]*r[i]*pi;
} double L=,R=maxr*maxr*pi;
for(int i=;i<;i++)
{
double m=(L+R)/;
if(ok(m)) L=m;
else R=m;
}
printf("%.4lf\n",R);
}
//fclose(stdin);
//fclose(stdout);
return ;
}

UVALive 3635 Pie(二分法)的更多相关文章

  1. UVALive 3635 Pie 切糕大师 二分

    题意:为每个小伙伴切糕,要求每个小盆友(包括你自己)分得的pie一样大,但是每个人只能分得一份pie,不能拿两份凑一起的. 做法:二分查找切糕的大小,然后看看分出来的个数有没有大于小盆友们的个数,它又 ...

  2. uvalive 3635 Pie

    https://vjudge.net/problem/UVALive-3635 题意: 有F+1个人要分n个蛋糕,他们得到的蛋糕的面积必须是一样的,但是每个蛋糕必须是整块的蛋糕,而不是有多块蛋糕拼成的 ...

  3. UVaLive 3635 Pie (二分)

    题意:有f+1个人来分n个圆形派,每个人得到的必须是一个整块,并且是面积一样,问你面积是多少. 析:二分这个面积即可,小了就多余了,多了就不够分,很简单就能判断. 代码如下: #pragma comm ...

  4. UVA 12097 LA 3635 Pie(二分法)

    Pie My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a numbe ...

  5. hdu 1969 Pie (二分法)

    Pie Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  6. LA 3635 Pie 派 NWERC 2006

    有 f + 1 个人来分 n 个圆形派,每个人得到的必须是一整块派,而不是几块拼在一起,并且面积要相同.求每个人最多能得到多大面积的派(不必是圆形). 这题很好做,使用二分法就OK. 首先在读取所有派 ...

  7. POJ 3122 pie (二分法)

    Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have ...

  8. POJ-3122.Pie(二分法最大化平均值)

    二分法的主题思路就是逐步逼近,所以这道题的思路自然一目了然,做题思路也是... 本题大意:题主过生日,它买了N块半径为R[ i ],高为1的圆柱形蛋糕,现在他要将这N块蛋糕等分给F + 1个人,为了好 ...

  9. UVALive 3635 分派

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

随机推荐

  1. SpringBoot2.1.0 application.properties配置

    # =================================================================== # COMMON SPRING BOOT PROPERTIE ...

  2. gstreamer-tips-picture-in-picture-compositing

    http://www.oz9aec.net/index.php/gstreamer/347-more-gstreamer-tips-picture-in-picture-compositing htt ...

  3. 【鸟哥的Linux私房菜】笔记

    操作系统核心的功能! 驱动程序与操作系统的关系 2. [计算机组成之组件] 3.CPU实际要处理的数据完全来自于主存储器,这是一个很重要的概念! 4.CPU是整个计算机系统最重要的部分,那么目前世界上 ...

  4. Shell编程之IF条件

    一.if条件语句的知识与实践 1.if条件语句语法(单分支结构) 第一种: if < 条件表达式 > then 指令 fi 第二种: if < 条件表达式 >; then 指令 ...

  5. 主攻ASP.NET.4.5.1 MVC5.0之重生:系统角色与权限(二)

    系统角色篇 数据结构 用户管理 Controller代码 public class SystemUserController : Controller { //public void Log() // ...

  6. 一、安装虚拟机,配置ip地址

    一.安装linux 注意点: 一.选择最小化安装的时候,要自定义安装软件,必须要安装下面的 如果没有安装上面的,需要用下面的命令来查询安装 如果没有安装就会出现各种问题 二.分区简单介绍 1.至少要一 ...

  7. jenkins tomcat

    tomcat增加用户配置: <role rolename="tomcat"/> <role rolename="role1"/> < ...

  8. R语言笔记003——set.seed()函数

    set.seed()函数 set.seed()设定生成随机数的种子,让样本可重复. > x<-rnorm() # 生成4个随机数 > x [] 0.6599492 0.5881863 ...

  9. Elasticsearch 存储模型

  10. Qt 自定义PushButton

    http://blog.csdn.net/zddblog/article/details/11116191 功能:鼠标弹起并在按键区域内时,按键响应.并实现normal.hover.pressed效果 ...