## UVALive 3635 Pie 切糕大师 二分

news2024/2/27 15:18:39

``````/*
*  Author:      illuz <iilluzen[at]gmail.com>
*  Blog:        http://blog.csdn.net/hcbbt
*  File:        live3652.cpp
*  Create Date: 2013-09-10 00:40:36
*  Descripton:  binary, greedy
*/

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int MAXN = 10010;
const double PI = acos(-1.0);

int n, f, t;
double a[MAXN], Max;

bool judge(double x) {
int sum = 0;
for (int i = 0; i < n; i++)
sum += a[i] / x;
if (sum >= f + 1) return true;
return false;
}

int main() {
scanf("%d", &t);
while (t--) {
scanf("%d%d", &n, &f);
for (int i = 0; i < n; i++) {
scanf("%lf", &a[i]);
a[i] = PI * a[i] * a[i];
Max = max(Max,  a[i]);
}
double low = 0, mid;
while (Max - low > 1e-5) {
mid = low + (Max - low) / 2;
if (judge(mid)) low = mid;
else Max = mid;
}
printf("%.4lf\n", low);
}
return 0;
}
``````

### vs 2012 +opengl

2019独角兽企业重金招聘Python工程师标准>>> I was recently helping a friend get set up running OpenGL and I realized that most of the instructions available online for this are fairly outdated. So, here’s a quick run through to set the record str…

### android之SharedPreferences

2019独角兽企业重金招聘Python工程师标准>>> 一、SharedPreferences应用场景 SharedPreferences 用于保存参数&#xff1b; 内部是以XML文件进行保存的&#xff0c;位于/data/data/package/shared_prefs目录中&#xff1b; 二、SharedPreferences核心代码 1.保存 Sh…

### 返回局部变量或临时变量的地址_值传递和地址返回两者在堆区(Heap)应用的三种易错点...

1、指针变量作为参数进行值传递给函数的形参&#xff0c;并在堆区(Heap)进行内存分配和赋值程序源码&#xff1a;1 结果&#xff1a;Segmentation fault (core dumped)分析&#xff1a;如上图&#xff0c;指针变量ptr进行值传递给函数allocation()的形参tmp并赋值为NULL&#x…

### tensorflow官方文档_Tensorflow 2.0 Preview 官方文档

TensorFlow 2.0目前放出了Preview版本。目前想了解TensorFlow 2.0最快的方式就是查看官方API中的变化。本文列举一些从TF官方API中看出的TF 2.0的改进。TensorFlow 2.0 Preview可以通过pip下载了:CPU: https://pypi.org/project/tf-nightly-2.0-preview/GPU: https://pypi.org/…

### Android ---- Context

Context字面意思上下文&#xff0c;位于framework package的android.content.Context中&#xff0c;很多方法需要通过 　Context才能识别调用者的实例&#xff0c;比如说Toast的第一个参数就是Context&#xff0c;一般在Activity中我们直接用this代替&#xff0c;代表调用者的 …